How to retrieve comments from a media in instagram?

为君一笑 提交于 2021-02-16 08:53:30

问题


I'm working on a project which aims to analyse instagram users' posts. I have a list of users and for each of them I have to crawl the recent media with the number of likes, comments and the text of comments. By using the recent media endpoint I've achieved some user media (of my user, using the access_token associated to my account). The result only gives the number of comments per media, but not the text. So I selected some media_id from this output and tryied to retrieve the comments associated to the media. But the result is ever

{"meta": {"code": 200}, "data": []}

The endpoint url that I use is

https://api.instagram.com/v1/media/{media-id}/comments?access_token=ACCESS-TOKEN

the access_token is generated with public_content, follower_list and basic scopes.

My app is in a sandbox, and I am the only one user of the sandbox. Any suggestion? thanks in advance


回答1:


You have to be in live mode and have public_content permission to get comments.

sandbox mode will only give you and your sandbox user's info in API response, if you or your sandbox user have commented on a media then that will only show in response, once u go live mode, all comments will be in response.

Also API will only give you maximum of 150 latest comments for any media, not all.




回答2:


You can use cURL to get 40 comment per 1 request likes this

"linkOfMedia"/?__a=1

and then take comment in graphql->shortcode_media->edge_media_to_comment->edges. If you want more you should take end_cursor at page_info object then add &end_cursor= after the link.



来源:https://stackoverflow.com/questions/40677006/how-to-retrieve-comments-from-a-media-in-instagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!