Displaying user information from Instagram PHP API

Sorry over-precise question, but I'm pretty new to this and can use some help. I thought I understood everything until I got to this checkpoint.

I am using the 9lesson Instagram PHP Oauth tutorial which is built on top of the Instagram PHP API.

Everything is working correctly, but I am trying to add a line that shows the logged in user, how many followers they have.

I added this third line by copying the first two lines that already existed.

echo '<b>Profile Pic:</b> '.$data->user->profile_picture.'</br>';
echo '<b>Access Token:</b> '.$data->access_token.'</br>';
echo '<b>Followed by</b> '.$data->user->counts->followed_by.'</br></div>';

      

I added the last line under $_SESSION['userdetails']=$data;

$followers =$data->user->counts->followed_by;

      

Why doesn't this return any data, even if it's the correct name for the endpoint? I feel like I've tried every possible combination of 10 things. Any help would be great!

+3


source to share


1 answer


I have looked at the Instagram API you are using.

It looks like you get $data

from this call

$data = $instagram->getOAuthToken($code);

      

This call is for getting an access token and calls this endpoint

https://api.instagram.com/oauth/access_token

      

if you look at the Instagram API you will see that this call does not return any values



{
    "access_token": "fb2e77d.47a0479900504cb3ab4a1f626d174d2d",
    "user": {
        "id": "1574083",
        "username": "snoopdogg",
        "full_name": "Snoop Dogg",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg"
    }
}

      

With its API, I'm not sure how to get the invoice. I have built an API (requires php 5.3+) which makes it very simple.

$current_user = $instagram->getCurrentUser();
$followers = $current_user->getFollowers(); //get first page of followers
$followers_count = $current_user->getFollowersCount(); //get number of followers

      

Here's an example

http://galengrover.com/projects/instagram/?example=current_user.php

+1


source







All Articles