android - Getting facebook user id using Facebook SDK -
i'm using facebook login @ app, , able neccesery information logged in user (first , last name, id. gender etc..) can open specific profile id. since i'm working latest facebook sdk i'm not able user id.
i've noticed there few changes in sdk issue thing i'm missing user id. can other information except id - gives me wrong id (17 digits).
when check through browser (using graph instead www) can see user id including 10 digits.
here's code:
private void onsessionstatechange(final session session, sessionstate state, exception exception) { if (state.isopened()) { log.i(tag, "logged in..."); @suppresswarnings("deprecation") requestasynctask request = request.executemerequestasync(session, new request.graphusercallback() { @override public void oncompleted(graphuser user, response response) { if (session == session.getactivesession()) { if (user != null) { user_id = user.getid();//user id profilename = user.getname();//user's profile name token = session.getaccesstoken(); . . . } else { . . } } } }); } else if (state.isclosed()) { log.i(tag, "logged out..."); } }
the issue upgrade of facebook sdk graph api v2.0. facebook gives unique id users, changing between apps, means given id not original user id.
changes v1.0 v2.0
app-scoped user ids: better protect people's information, when people log version of app has been upgraded use graph api v2.0, facebook issue app-scoped id rather person's orginal id.
my solution using browser , not facebook application. url should this:
http://www.facebook.com/givenuserid
and code:
startactivity(new intent(intent.action_view, uri.parse("http://www.facebook.com/"+userid)));
Comments
Post a Comment