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.
Related
I've got Facebook login working on my web app. On successful login, I'm getting the users app-scoped id. My question is, how do I pre-identify what a certain user's app-scoped id is, so I can add that id to my users table?
To be clear, if Facebook user "Bob" has a userId of 55512, and has paid for access to my app, how do I look up his app-scoped id for my app, so I can add that ID to my users table, identifying him as a valid user?
According to latest Facebook graph API we cannot fetch user / profile id from Facebook username as
graph.facebook.com/username
Then how these websites are fetching user / profile id from usernames.
https://lookup-id.com/
http://findfacebookid.com/
http://findmyfbid.com/
etc...
They are scraping the profile, which is not allowed. If you need to get a User ID, authorize the User with your App and you will get an App Scoped ID. That´s all you need.
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...
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
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.