Search code examples
phpinstagraminstagram-api

Get basic information of instagram page


I have number of instagram pages/urls of different users like https://instagram.com/xxxxx/ etc etc etc. I want to get following information of that page

name, number of followers, description, bio,

I have searched and all showing using access token. But I am confused if I will take access token from my account, how can I get information of other pages?

Please guide me how can I do that?


Solution

  • You need access token to work with Instagram API. So if you get an access token you can use Instagram API.

    To get basic information about a user, use this:

    https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN

    {user-id} is NOT username. To get {user-id} from username, use this:

    https://api.instagram.com/v1/users/search?q=[USERNAME]&access_token=[ACCESS TOKEN]

    To get access token use this:

    https://instagram.com/oauth/authorize/?client_id=[CLIENT_ID_HERE]&redirect_uri=http://localhost&response_type=token
    

    And finally the response would be something like:

    {
        meta: {
            code: 200
        },
        data: {
            username: "lanadelrey",
            bio: "Put not your trust in princes, nor in the son of man, in whom there is no help",
            website: "http://www.lanadelrey.com",
            profile_picture: "https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10948781_564619503641170_898618667_a.jpg",
            full_name: "Lana Del Rey",
            counts: {
                media: 114,
                followed_by: 4207076,
                follows: 78
            },
            id: "305506437"
        }
    }