I have a script built that shows a "ticker" of a clients Instagram followers.
A few weeks (or maybe months) back, it stopped working, and has just shown "0".
I have tried both file_get_contents as well a cURL, and neither seem to work.
Or perhaps more accurately... they work for approximately 5 seconds, and then stop again.
What's strange is, if I go to the graph URL (https://www.instagram.com/account_name_here/?__a=1), I can see the JSON that it spits out, no matter how many times I reload the page.
But, running the following code:
$ch2 = curl_init();
$url = "https://www.instagram.com/account_name_here/?__a=1";
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_URL,$url);
$result=curl_exec($ch2);
curl_close($ch2);
$data = json_decode($result, true);
$followerCount = $data['graphql']['user']['edge_followed_by']['count'];
echo "Followers: ".$followerCount;
Spits out nothing.
Doing a var_dump() on various other pieces of this, including $result and $data reinforce the idea that nothing indeed is getting pulled in.
If I do var_dump($result) for example, it spits out:
string(0)""
It is particularly infuriating that the first time I switched to using cURL over file_get_contents, it worked. And then as soon as I uploaded it to the website, it stopped working again.
Any idea what I am missing here? Why when I go to the actual instagram URL I see the data fine, but as soon as I try to pull it via PHP, it doesn't work?
TIA!