使用Android中的SDK 3.15登录Facebook时获取UserName

时间:2014-06-19 11:27:57

标签: java android facebook username

今天我试图实现新的facebook sdk v3.15.0,我在获取GraphUser对象后检索用户名时出现问题。

在实施新的Facebook SDK之前,我使用的是facebook-android-sdk-3.7,我设法接收用户名,在这里我将发布我的GraphUser对象:

GraphObject{graphObjectClass=GraphUser, state={"id":"10000*******","first_name":"****","username":"him.her","timezone":2,"email":"ultimo****@yahoo.com","verified":true,"name":"*** D**a","locale":"en_US","link":"https:\/\/www.facebook.com\/k***o.d****","last_name":"D****a","gender":"male","updated_time":"2014-03-03T10:10:54+0000"}}

当我实现新的facebook SDK时,我收到的GraphUser对象是:

GraphObject{graphObjectClass=GraphUser, state={"id":"153****","first_name":"***i","timezone":2,"email":"ol***@yahoo.it","verified":true,"name":"O*** S***","locale":"en_US","link":"http:\/\/www.facebook.com\/1*****","last_name":"****e","gender":"male","updated_time":"2014-04-22T19:59:34+0000"}

我用它来获取GraphUser:

......
@Override
public void onUserInfoFetched(GraphUser user) { ....

问题

使用新SDK登录Facebook时如何获取用户名?

由于

1 个答案:

答案 0 :(得分:2)

Graph API v2.0不再提供username字段。在这里查看我的答案:Omniauth-facebook hash not showing Facebook 'username' field, using rails 3