How to get Self Instagram User ID


In previous tutorial I have explained how to Get Instagram Access Token Using Client-Side Authentication. Now In this tutorial I will show you how to get self Instagram user ID.

Get self Instagram User ID:

Click Here to receive Instagram Access Token. Now using this token, you can get self basic details like username, profile pic, bio, etc by following URL:

https://api.instagram.com/v1/users/self/?access_token=your_access_token

I have created a function getSelfInstaID() to get self instagram user id using access token.

function getSelfInstaID(){
    $token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 
    $url = "https://api.instagram.com/v1/users/self/?access_token=".$token;
    $get = file_get_contents($url);
    $user = json_decode($get);

    if($user->data){
        return $user->data->id;
    }

    return '00000000'; // return this if nothing is found
}

Hope this tutorial will help you to get self instagram user id.