FB API v2.0 app-scoped users issue - facebook

A few weeks ago, we started working with facebook graph api v2.0 instead of v1.0.
As mentioned in the FB documentation, the fbId of users who logged in to our app with v1.0 not suppose to be effected by the upgrade and only new users with v2.0 will get app-scoped id instead of general id.
But, some of our old users from v1.0 somehow got the app-scoped id instead of general id and it surprised us since it was not suppose to happen.
We wanted to add in our server code a kind of a patch for it, which will get the app-scoped id by the general id or the general id by the app-scoped.
After some reading we saw the api call:
https://graph.facebook.com/v2.0/…<general/app-scoped_id>&access_token=<SomeToken>
But instead of returning the id we wanted it returns the same id we asked.
For example:https://graph.facebook.com/v2.0/123456&access_token=SomeToken
will return :
{ http://www.facebook.com/123456: {
id: "http://www.facebook.com/123456"
}
Can anyone help us figure out why isn`t it working?

As far as I know, you cannot get the scoped_id from the canonical id, and viceversa. But if you get the scoped_id, for instance, from a request from field (which always give you the scoped_id), then you can ask for the [scoped_id]?fields=id and you will get the user id registered for your app, which is the canonical one if the user registered before your migration to v2.0 or the scoped id if he registered after your migration.
In remune, what you can convert is:
[app-scoped_id] --> [general/app-scoped_id]

Related

get Facebook user ID with username without graph api [duplicate]

I would like to retrieve a Facebook user's id given their username.
Example: Given helloworld return 100003263065603.
I understand that the Graph API does not allow this anymore, but several sites, such as lookup-id and findmyfbid are able to do this.
I am guessing they are doing some sort of scraping? If so, how would I implement this in Node.js
Those sites most likely scrape the profile page, which is not allowed. Don´t do that, should not need to anyway. Just let the user authorize your App and you will get his (App Scoped) ID. There´s no serious application for using the username or his global ID anymore.

Get correct id from facebook

I'm trying to get a username from facebook id - I found a way to do it:
https://graph.facebook.com/id?fields=link
however, i noticed that using the graph api, when writing 'me' in the fileds I get a different id from when I use this site :http://findmyfacebookid.com/
And only when using the id from the http://findmyfacebookid.com/ site, the https://graph.facebook.com/id?fields=link works
Anyone knows how to get the id that works every time using the graph api?
Thank you!
Since v2.0 you only get an "App Scoped ID", there is no way to get the "real" ID anymore, and there is no way to get the "username" either. See the changelog for more information.
You should not need the username anyway. If you want to identify returning users, you can just use the App Scoped ID. And if you need to match user between different Apps, you can use the Business Mapping API.

how to map old facebook id with new facebook scoped id?

Im using FB App for my site, in that FB announced that graph api, new api will return app scoped id instead of fb user_id. I used to store all my FB user_id to table and retrieve data for next time by matching user_id.
Now new api will provide scoped_id its new to all users so how can i figure out this user is already register in our site?
Simply, how to find out the user is already logged with us by comparing or getting user_id ?
how can i get user_id by passing scoped_user_id ?
I think mapping is not necessary, have a look at
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
No matter what version they originally used to sign up for your app, the ID will remain the same for people who have already logged into your app. This change is backwards-compatible for anyone who has logged into your app at any point in the past.

How app_scoped_ids will be used on custom audience after May 1st?

On custom audience, there is the possibility to upload a Facebook ID list for creating an audience... After the Graph API v2.0 migration, when we won't have access to Facebook ID anymore, how can i upload the user id list? Can i use a app_scoped_id based list?
If someone publishes something on my fanpage, and i get his post using Graph API, will i be able to use his id on custom audience? The official documentation don't make itself clear when explaining about the "expiring process" of a app_scoped_id. As far as i understood, when someone authorizes an application, his app_scoped_id will be "permanent", but if there is no user interaction/authorization with my application, the app_scoped_id CAN expire in 24 hours... is that right? If so, how can i use a list of ids on custom audience if they expires?
Thank you!
UPDATE
From https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids:
For users who have not logged into your app, the user ID may change depending on the version of the API that you call. In v1.0 of the API users who have not logged into your app will be referred to by their original Facebook user ID, whereas in v2.0 they will be referred to by an app-scoped ID.
We've added new API endpoints that allow you to tag and invite friends who don't use your app. These APIs return tokens which may be used to generate custom interfaces for tagging and invitations. Those tokens aren't meant to be cachable and we make no guarantees that they will be stable beyond 24 hours from the time the API response containing them was received. They aren't the same as either the IDs used on data for people not logged into your app nor the same as the app-scoped IDs.
You are confusing the app-scoped IDs with temporarily generated IDs. App-scoped IDs will not change over time. Temporarily generated IDs are meant to help with inviting and tagging friends who have not authorized an application and as such they will not remain the same over time.

Get Users App-Scoped user id in Facebook Graph API

In advent of the new V2 Facebook Open Graph API, I need to make note of the logged in users 'App-Scoped' user ID, in order to register the id with Parse in order to receive PUSH notifications.
However, as the logged in user I get the Facebook ID instead.
Haven't found anything in the docs to solve this problem yet, so thought I better ask here.
If you created your facebook application before the introduction of graph API 2.0, It will continue to receive the canonical facebook user ID
If you created your facebook application, after the introduction of graph API 2.0, It gives you app scoped id instead of the canonical id.
In this case I assume your application is quite old.Therefor create a new app and it will give you the app scope id.
In facebook document:
"The id of this person's user account. This ID is unique to each app
and cannot be used across different apps. Our upgrade guide provides
more info about this." You only get id with each apps.
more information in here: facebook.developers
The "Facebook ID" as you call it IS the App-scoped User ID.
See https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
The id you get from the api's is an opaque string, and you should use it as such.
If the user has already granted your app access on v1, then your app will continue to receive the same id.
The old users who have registered keep receiving the canonical ID from Facebook for those users, and new users are getting the new scoped ID. Although it is working fine as a long integer, I suggest to change the long field for a string field (unless you already treat it as a string), because we cannot know what Facebook will send here in the future. To keep your code mainly unchanged, create a new internal user id long integer which will be the one your code is already using, and relate it with the string ID from Facebook, which is canonical or scoped, depending if the user registered before or after the migration, and which you will have to manage only for logins, requests, open graph stories, etc.
This way you have not worry about canonical or scoped id EXCEPT one case. Everything works fine, except we found a problem, and maybe somebody can correct me and so help me to solve this: when a new user accept a invite request from an existing user, when your app reads the ID of the sender of the request, I found that Facebook gives you the new scoped id ALWAYS, no mater if the referrer is old or new user. This way, if a user registered before the migration, you have stored the canonical ID, and later, you read a request from this user accepted for a new one, you get the scoped id from the old user, but what you have stored is the canonical one! As result, old users can no more invite new users properly! If anyone knows how getting canonical ids from requests sent for old users, or knows how to obtain the scoped ids for the existing users with canonical ids (to store the new scoped ids in the database) it would be very helpful to hear their suggestions.