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.
Related
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.
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]
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.
I'm trying to write some application that scan user's group posts. When I read the group feed posts using the API I’m interested to get some information on the one who posted this post ('from' field). The graph API today gives only the id and the name of this person. I'm interested also in his work place. I tried taking the user id and to access the / resource and to get his work field , but this field is not returned. When I’m looking on the same user profile in Facebook I see his work place is public, even I’m not connected with him.
Anything I can do to get this user work with the existing Facebook API?
Normally, if the work history info is not public, you'll need the "user_work_history" permission (see https://developers.facebook.com/docs/facebook-login/permissions#reference-extended-profile).
If it's public, you can try calling the
/{USER_ID}?fields=id,work
I need the following, any help would be much appreciated.
I Have a registration form.
It inputs the data Name | ID | DOB | TWITTER | FBID
When the user registers it asks for the above values.
Twitter is easy as users can just put in their Twitter ID.
But I Need to get the users Facebook ID in the form.
What would be the best way to do this?
Could i use the 'Connect To Facebook" Feature.
All i need is the Facebook user ID so that i can use it when retiring graph data later on.
I have set up a Facebook Application and am using PHP with a MySQL database.
Thanks
Alex
Well, they have specific APIs for different functions. In your case none of their simple solutions work. You will probably need to use Facebook's Graph API. You should take a look in their PHP SDK. It is a very useful tool. I used it once and it worked perfectly.
You will need to know much, before you get the users is. Also if you want to make that automatically, they will have to be logged in and they will have to confirm access to their personal data from your facebook app.
Good luck!
For any user data you wll need to get permission from user.
You can use Facebook connect.
Make the user log in and get access token, this access token is the key to all user data.
You can use this access token with graph API also.
Check my blog.