Facebook user url by id

Facebook

Facebook Problem Overview


I have a list of FB ids, is there a canon way of constructing their FB url without a graph query?

For example, I have ids 3, 4, 5, and i want the Facebook URL for them without using the graph api and save them down

Facebook Solutions


Solution 1 - Facebook

UPDATE 2: This information is no more given by facebook. There is an official announcement for the behavior change (https://developers.facebook.com/blog/post/2018/04/19/facebook-login-changes-address-abuse/) but none for its alternative.

Yes, Just use this link and append your ID to the id parameter:

https://facebook.com/profile.php?id=<UID>

So for example:

https://facebook.com/profile.php?id=4

Will redirect you automatically to https://www.facebook.com/zuck Which is Mark Zuckerberg's profile.

If you want to do this for all your ids, then you can do it using a loop.

If you'd like, I can provide you with a snippet.

UPDATE: Alternatively, You can also do this:

https://facebook.com/<UID>

So that would be: https://facebook.com/4 which would automatically redirect to Zuck!

Solution 2 - Facebook

Accepted answer didn't work for me, this does:

https://www.facebook.com/app_scoped_user_id/10152384781676191

Solution 3 - Facebook

The easiest and the most correct (and legal) way is to use graph api.

Just perform the request: http://graph.facebook.com/4

which returns

{
   "id": "4",
   "name": "Mark Zuckerberg",
   "first_name": "Mark",
   "last_name": "Zuckerberg",
   "link": "http://www.facebook.com/zuck",
   "username": "zuck",
   "gender": "male",
   "locale": "en_US"
}

and take the link key.

You can also reduce the traffic by using fields parameter: http://graph.facebook.com/4?fields=link to get only what you need:

{
   "link": "http://www.facebook.com/zuck",
   "id": "4"
}

Solution 4 - Facebook

The marked answer seems outdated and it won't work.

Facebook now only gives unique ID related to app which isn't equal to userId and profileUrl and username will come out to be empty.

Doing me?fields=id,name,links is also depreciated after Graph Version 2.4

The only option now is to request for user_links permission from your developer console.

enter image description here

and the pass it in scope when doing facebook login

scope: ['user_link'] }

or by doing an api call

Solution 5 - Facebook

As of now (NOV-2019), graph.api V5.0

graph API says, refer graph api

> A link to the person's Timeline. The link will only resolve if the person clicking the link is logged into Facebook and is a friend of the person whose profile is being viewed.

doc

Solution 6 - Facebook

I've collected info together:

And finaly: it doen't work without additional Facebook permission check:(

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTimmyView Question on Stackoverflow
Solution 1 - FacebookSyed I.R.View Answer on Stackoverflow
Solution 2 - FacebookdavidhqView Answer on Stackoverflow
Solution 3 - FacebookzerkmsView Answer on Stackoverflow
Solution 4 - FacebookiRohitBhatiaView Answer on Stackoverflow
Solution 5 - FacebookGambitierView Answer on Stackoverflow
Solution 6 - FacebookGrigory KislinView Answer on Stackoverflow