2

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"
James Fazio
  • 6,370
  • 9
  • 38
  • 47

3 Answers3

8

Something like:

String response = facebook.request(userId);

JSONObject json = Util.parseJson(response);
String name = json.getString("name");
String username = json.getString("username");
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
6

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"
}
Lix
  • 47,311
  • 12
  • 103
  • 131
0

https://graph.facebook.com/UserID. eg: https://graph.facebook.com/19292868552

Vishnu Mohan G
  • 622
  • 1
  • 7
  • 14
  • 1
    Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Lix May 25 '12 at 21:38