I am using WordPress and trying to figure out the simplest way to display the amount of Instagram followers a user has.
Whilst searching I have found a few Instagram PHP wrapper scripts that seem a little overkill for what I am trying to display.
From reading through the Stackoverflow posts I came across a post that listed this code:
$userinfo = wp_remote_get("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$userinfo = json_decode($userinfo);
$followers = $userinfo['data']['counts']['followed_by'];
echo "Folled by: " . $followers . " people";
This is a simple and perfect script HOWEVER it does not return any data.
I have setup a client on the Instagram Developer site however I cannot get the above script to display any data.
Any help would be greatly appreciated.
Try this:
$result = file_get_contents("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$obj = json_decode($result);
echo $obj->data[0]->id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With