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