简体   繁体   English

从 Twitter 状态/user_timeline 获取照片

[英]Getting photos from Twitter statuses/user_timeline

Using the Twitter API, I can get all the user's Tweets with location information.使用 Twitter API,我可以获取所有用户的带有位置信息的推文。 If they use a mobile app and attach photos, how can I get this from the API?如果他们使用移动应用程序并附上照片,我如何从 API 获取此信息?

First of all, you need to include include_entities=true as part of the request:首先,您需要在请求中包含include_entities=true

ie https://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitter&include_entities=truehttps://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitter&include_entities=true

Then, look for any media_url elements;然后,查找任何media_url元素; those will contain the URL to any photos.这些将包含任何照片的 URL。 It may contain video links, so you'll have to filter for common image types (.png/.jpg/.gif/etc).它可能包含视频链接,因此您必须过滤常见的图像类型(.png/.jpg/.gif/等)。

See: Tweet Entities请参阅:推文实体

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM