问题
We have an app available in android, ios and web. The app uses facebook login(using easyfacebook.jar) as alternate way of authorizing users. It was working fine but due to recent changes in facebook sdk I am unable to get the actual facebook id as the facebook api returns app-specific user id. From the facebook page:
Changes from v1.0 to v2.0
App-scoped User IDs: To better protect people's information, when people log into a version of your app that has been upgraded to use Graph API v2.0, Facebook will now issue an app-scoped ID rather than that person's orginal ID. However, for users that have previously logged into your app, the user ID will not change.
The id that I am getting are different for ios, web and android. Please take a look:
ios and web https://www.facebook.com/559709594 //return's actual userID
Android https://www.facebook.com/10152580446094595 //not returning actual userId
I tried the official facebook sdk to get the actual user id but it was not successful. I am trying to get user id using the following way:
user = graphApi.getMyAccountInfo();
facebookIdLogin = user.getId();
//returns app specific id not actual user id id = 10152580446094595
Log.d("username is : ", user.getName());//return actual value
Log.d("facebook id is this", facebookIdLogin);
Log.d("facebook user link", user.getLink());
//returns www.facebook.com/10152580446094595
Is there any way for me to get the actual userId. I need the actual userId because of synchronization between the platforms. Whatever I do I am only getting the app specific userId. Here's the permission I am requesting:
String permissions[] = { "public_profile", "user_friends", "email" };
Any help is highly appreciated.
回答1:
What you're seeing is the difference between an app-scoped user_id which was introduced with the Graph API v2.0, and the global user_id.
Have a look at https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids for the details.
回答2:
This question was just a misunderstanding. All the versions were receiving profile id different than the actual profile id. In android I had a separate dashboard configured so I was receiving different id. Note the id will be same for the same project in the same dashboard with same account.. Hope this helps someone.
来源:https://stackoverflow.com/questions/24544741/facebook-login-issue-unable-to-get-users-actual-facebook-id