问题
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