2012-05-25 69 views

回答

6

簡單的查詢與user_id圖形API應該足以讓用戶的名稱得到了用戶的圖片 -

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" 
} 

您可以通過爲名稱字段添加過濾器來進一步深入研究 -

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

{ 
    "name": "Mark Zuckerberg", 
    "id": "4", 
    "type": "user" 
} 
8

是這樣的:

String response = facebook.request(userId); 

JSONObject json = Util.parseJson(response); 
String name = json.getString("name"); 
String username = json.getString("username");