Facebook Developer : How to Get User Name Using Facebook User ID


When you are developing a facebook app, in many cases u need to know the name of the user. Normally you get it if the user gives the basic permission. But if you don’t want to store the name of the user you just want to store the user ID only and later when you need the Name of the user then you can get that easily and anytime. Below is how you can get it in PHP.


$user_details_encoded = file_get_contents("https://graph.facebook.com/User_ID?fields=name");  
$user_details_decoded = json_decode($user_details_encoded,true);
$user_name = $user_details_decoded['name'];

Here $user_name gives you the name of the required user.

Tagged with: ,
Posted in Facebook Apps Development
One comment on “Facebook Developer : How to Get User Name Using Facebook User ID

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow me on Twitter

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 442 other followers

%d bloggers like this: