Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get Facebook User Name from their ID number

Is it possible to get a Facebook user's name from their Facebook Id number with a graph call? If so, does anyone know the call?

For example you can get a user's picture by making the following call

  "http://graph.facebook.com/" + someUserId + "/picture"
like image 531
James Fazio Avatar asked Nov 20 '25 17:11

James Fazio


2 Answers

Something like:

String response = facebook.request(userId);

JSONObject json = Util.parseJson(response);
String name = json.getString("name");
String username = json.getString("username");
like image 61
Nitzan Tomer Avatar answered Nov 23 '25 06:11

Nitzan Tomer


Simply querying the Graph API with the user_id should be enough to get the name of the user -

http://graph.facebook.com/4     
>>

{
  "id": "4", 
  "name": "Mark Zuckerberg", 
  "first_name": "Mark", 
  "last_name": "Zuckerberg", 
  "link": "https://www.facebook.com/zuck", 
  "username": "zuck", 
  "gender": "male", 
  "locale": "en_US", 
  "updated_time": "2012-05-20T01:29:18+0000", 
  "type": "user"
}

You could drill down even more by adding a filter for the name field -

https://graph.facebook.com/4?fields=name
>>

{
  "name": "Mark Zuckerberg", 
  "id": "4", 
  "type": "user"
}
like image 24
Lix Avatar answered Nov 23 '25 06:11

Lix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!