Instagram followers count

删除回忆录丶 提交于 2019-12-13 07:57:40

问题


For few days ago page https://www.instagram.com/<username>/?__a=1 returns 403 error. Is there another easy way to get account followers?


回答1:


This was one of the undocumented endpoints it has to be stopped at some point because it was not supposed to be accessible to public. It is really recommend to not to use these undocumented endpoints in your app instead use Instagram API.

However You can get edge_followed_by using this php solution, I haven't tested it but you can try :-

$name = "{username}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.instagram.com/$name/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($http=="200") {
  $doc = new DOMDocument();
  $doc->loadHTML($result);
  $xpath = new DOMXPath($doc);
  $js = $xpath->query('//body/script[@type="text/javascript"]')->item(0)->nodeValue;
  $start = strpos($js, '{');
  $end = strrpos($js, ';');
  $json = substr($js, $start, $end - $start);
  $data = json_decode($json, true);
  $user_id = $data["entry_data"]["ProfilePage"][0]["graphql"]["user"]["edge_followed_by"]["count"];
}  


来源:https://stackoverflow.com/questions/49828694/instagram-followers-count

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