Instagram 粉丝数量

Instagram followers count

几天前页面https://www.instagram.com/<username>/?__a=1 returns 403错误。还有其他获得帐户关注者的简单方法吗?

这是未记录的端点之一,它必须在某个时候停止,因为它不应该被 public 访问。真的建议不要在您的应用程序中使用这些未记录的端点,而是使用 Instagram API.

但是您可以使用此 php 解决方案获得 edge_followed_by,我还没有测试过,但您可以尝试 :-

$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"];
}