Retrieving more than 150 Instagram comments

谁说胖子不能爱 提交于 2019-11-29 19:31:07

Ok, This is going to be a very "Hacky" solution, and I am not currently setup to do this myself (due to lack of ADSL at home) but I can provide a step by step guide of how I would approach this issue.

First of all you will need a tool called "Charles Web Debuging Proxy"

There is a tutorial on the site on how to enable "SSL debugging" in charles, (which will require you to install a new "root certificate" on your mobile device, to trick it into thinking that https transactions signed by charles are actually signed by instagram.com )

Now Set your mobile device to route all requests through said proxy ( which will have to be installed on your local wi-fi network.)

go to https://www.google.com and check that charles is logging both requests and responses.

Once this is all setup correctly then you can take a look at the API calls which the instagram app itself uses to generate said comment pages.

The generic answer here is "no, that's not possible via regular endpoints".

Instagram updated Rate Limits (after Nov 17, 2015). All rate limits on the Instagram Platform are controlled separately for each access token, and on a sliding 1-hour window. Live apps have higher rate limits than apps in Sandbox Mode.

Which state next limitations in global context:

Global Rate Limits

Global rate limits are applied inclusive of all API calls made by an app per access token over the 1-hour sliding window, regardless of the particular endpoint. Rate limits also apply to invalid or malformed requests.

  • Sandbox RATE LIMIT: 500 / hour
  • Live RATE LIMIT: 5000 / hour

Plus separately limitations for comments endpoints:

Endpoint-Specific Rate Limits

Endpoints used to publish (POST or DELETE) have rate limits that are applied on an per-endpoint basis. Any calls made to these endpoints by your OAuth Client are also counted towards the global rate limits noted above.

  • Sandbox /media/media-id/comments: 30 / hour
  • Live /media/media-id/comments: 60 / hour

If your app exceeds any of these rate limits, you will receive a response with an HTTP response code of 429 (Too Many Requests).

As soon as Instagram Platform controls it on per access token basis, you might achieve a bigger limits using multi-threading with multiple access tokens. But it has caveats: 1. not everything could be paralleled from multiple access tokens, as context will be different. 2. It might contradict with Platform Policy and TOS

This isn't "hacky" at all.

As Instagram gives the link where you are able to get recieve all comments here: https://instagram.com/developer/endpoints/comments/

All you have to do is Looping over the link Instagram is giving you. I've done it like this. Im using the Api to do it this way.

  public function getUserMediaComments($id, $limit = 0) {
    return $this->_makeCall('media/'.$id.'/comments', true, array('count' => $limit));
  }

The $id is the media_id of the picture. If you foreach over that function with the picture id you'll recieve all comments.

It wasn't that hard when I found out about this way.

You could also do it like this while foreaching over it. :

$comments = json_decode(file_get_contents('https://api.instagram.com/v1/' . 'media/'. $image->id . '/comments?access_token='. $data->access_token));

It both returns you an array of the comments of the picture(s).

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