Reputation: 570
I'm using tweepy
to develop the program that retrieves media urls and download them. While testing some tweets, I found something weird. So this is what I did:
import tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
status = api.get_status(908827394856947712)
The original url of this tweet is 'https://twitter.com/realDonaldTrump/status/908827394856947712' and this tweet DOES contain an image. While studying status._json
, I figured out that the links of media files are contained in either status._json['entities']
or status._json['extended_entities']
but I couldn't find ['extended_entities']
and ['entities']
doesn't contain image link.
What makes me annoying is that some tweets have this problem and most do not. So why does this happen and how can I solve this problem?
Upvotes: 1
Views: 1107
Reputation: 14304
If you take a look through the response, you will see "truncated": true,
Twitter recently changed how tweets are presented - see their documentation https://dev.twitter.com/overview/api/upcoming-changes-to-tweets
With your request, you need to set tweet_mode=extended
So: api.get_status('908827394856947712', tweet_mode='extended')
Upvotes: 2