How to get the FacebookUserId with graph api explorer? - facebook

With this URL: /v2.2/me?fields=id, I can retrieve the user's id. (with the user's token of course)
But I noticed that it doesn't correspond to its FacebookUserId thanks to this link.
My goal is to reach the profile user through my Cordova app using this url scheme:
fb://profile/facebookUserId
since fb://profile/id does not work for every user...
What is this distinct id?

If you have an app-scoped User ID, you can use the following URL scheme to link to his/her profile
https://www.facebook.com/app_scoped_user_id/{app_scoped_id}/
where {app_scoped_id} is the numeric app-scoped User ID.
See:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/#fields

Related

Get Facebook profile URL from app-scoped user ID

A Facebook user's profile URL is http://facebook.com/USER_ID. However, with an app-scoped user ID, http://facebook.com/APP_SCOPED_USER_ID doesn't redirect to the user's profile page. How can I reach an user's profile page using just an app-scoped user ID?
Use the link field of the user object. This will look like the following:
https://www.facebook.com/app_scoped_user_id/{app_scoped_user_id}/
The URL - https://www.facebook.com/app_scoped_user_id/{app_scoped_user_id}/ - is access limited, only X request can be made on Y period of time from an account.
I did build a tool to crawl facebook's username base on app-scoped uid, by making a request to that scoped uid profile, I can parse the redirect header to find out the username.
The access limitation makes me suck. :(
You can use url format:
http://fb.com/app_scoped_user_id/{app_scoped_user_id}
example
http://fb.com/app_scoped_user_id/10101640953722381
If you want to get real facebook id from app scoped user id: https://stackoverflow.com/a/34450491/2181069
Tested that the above answer: https://www.facebook.com/app_scoped_user_id/{app_scoped_user_id}/ works for new user that connect to your app after migration.
As stated in FB documentation, existing connected users will continue to return the global ID. And it seems that https://www.facebook.com/app_scoped_user_id/{existing_user_global_id}/ won't work.
Thus, need to differentiate between existing and new user and use the global url (https://www.facebook.com/{user_global_id}) and app-scoped URL accordingly. Kind of tedious...

Getting Facebook Profile URL from Facebook App-scoped id

I just learned that starting with the Facebook API 2.0 , users registering with apps will get a unique facebook id specific to that app.
In my application, I need the user's profile url. The response I get from calling the graph's "/me" path looks like this:
https://facebook.com/app_scoped_user_id/{app_scoped_user_id}
But this will not take me to the user's profile unless I am logged in. Whereas using the real facebook id will take me to the public profile regardless of my logged-in state.
My question is: How to get the public user profile url from the app-scoped facebook id, or how to get the real facebook user id from the app-scoped id?
Thanks.

Post to user page from app on server

I have got the APP token using https://graph.facebook.com/oauth/access_token
I have got the usser access token using https://www.facebook.com/dialog/oauth?client_id
I now what to to publish on the user FaceBook page and it appears I need to USER_ID
Where is that?
I am looking to publish using https://graph.facebook.com/[USER ID]/feed
The user id is the number or facebook user of the user where you want to post...
When you see the url from your home you see:
https://www.facebook.com/profile.php?id=4
https://www.facebook.com/zuck
In this case you can use 4 or zuck for that.

Getting a user's ID using Facebook's Graph API

Is it possible to get the ID (Facebook Graph API) of a user who is currently logged in, without any access tokens?
If not, then how do I get new access tokens every time a user visits my page?
You will need to init the Facebook Javascript SDK and the user will have to have authorized your app at least one time. After that when the user visits your page as long as they are logged into Facebook you'll have access to the id and can retrieve it using
FB.getLoginStatus
the response will contain the information you're looking for.
Check this blog post for more details on setting up the FB init and the initial login.
https://developers.facebook.com/blog/post/525/
You can check the facebook ID using their username
http://graph.facebook.com/radrivan
You can use the javascript sdk to get their accesstoken and let them allow your app.
https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.2

Get Facebook User Id of my website visitors w/o auth

Is there any way to get the Facebook User Id of visitors in my website by using the FB API, but without need to ask them to authenticate my Facebook app?
All I need is some facebook-related-identifier, it does not even have to be the User Id, but any kind of identifier that can relate the user to a facebook profile.
Ideas?
If the user does not explicitly authorize you to get some private data from his Facebook account (included his Facebook ID), you can not get them.
I cannot think of a way to get the Facebook ID without the authorization of the user.
Hope that helps.