我正在使用以下网址来获取用户推文。
https://api.twitter.com/2/users/{user_twitter_id}/tweets
Run Code Online (Sandbox Code Playgroud)
以下是我的请求参数
query_params = {
'max_results': max_results,
'expansions': 'attachments.media_keys',
'tweet.fields': 'id,created_at,text,author_id,in_reply_to_user_id,referenced_tweets,attachments,withheld,geo,entities,public_metrics,possibly_sensitive,source,lang,context_annotations,conversation_id,reply_settings',
'media.fields': 'media_key,duration_ms,height,preview_image_url,type,url,width,public_metrics,non_public_metrics,organic_metrics,promoted_metrics,alt_text'
}
Run Code Online (Sandbox Code Playgroud)
以下是我在“包含”中收到的回复,其中包含媒体列表
"includes": {
"media": [
{
"height": 750,
"media_key": "3_1489397927281840131",
"type": "photo",
"url": "https://pbs.twimg.com/media/FKtnhhDWUAMtyBi.jpg",
"width": 1125
},
{
"height": 750,
"media_key": "3_1489397930452783110",
"type": "photo",
"url": "https://pbs.twimg.com/media/FKtnhs3XEAYeMkP.jpg",
"width": 1125
},
{
"height": 750,
"media_key": "3_1489397944214302727",
"type": "photo",
"url": "https://pbs.twimg.com/media/FKtnigIXMAcTO6t.jpg",
"width": 1125
},
{
"duration_ms": 242784,
"height": 1080,
"media_key": "13_1489018359819771906",
"preview_image_url": "https://pbs.twimg.com/media/FKoOePDWYAA1ZZB.jpg",
"public_metrics": {
"view_count": 275300
},
"type": "video",
"width": 1920
},
{
"height": 2400,
"media_key": "3_1488933061307809794", …Run Code Online (Sandbox Code Playgroud)