简体   繁体   中英

Get UserName when login with Facebook using SDK 3.15 in Android

Today I was trying to implement the new Facebook sdk v3.15.0 and I had a problem with retrieving username after getting GraphUser object.

Before implementing the new Facebook SDK I was using facebook-android-sdk-3.7 and I managed to receive username, here i will post my GraphUser object:

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

When I implemented the new Facebook SDK, the GraphUser object that I received was this:

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

I use this to get the GraphUser:

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

Problem

How can I get the username when I log in with Facebook with the new SDK?

The username field is no longer available with the Graph API v2.0. Have a look at my answer here: Omniauth-facebook hash not showing Facebook 'username' field, using rails 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM