Facebook Graph Api 2.1 get userid from username

一曲冷凌霜 提交于 2019-12-05 01:08:43

graph.facebook.com/username has stopped working. There is an unpleasant workaround. In my limited testing, this works in Chrome.

Wherever you see the facebook user name in a timeline entry, right click and select "inspect element." In the window that opens, scroll up a little and look for the string:

"data-hovercard="/ajax/hovercard/hovercard.php?id=".

The Facebook id of the username you right clicked on follows the = sign.

This only seems to work on names on the timeline.

You can send HTTP request to the facebook profile page from your server-side code
i.e. request to https://facebook.com/some_username
Parse the received response containing HTML source code and search for a <meta> tag that has a content attribute with a value looking like this fb://profile/xxx where xxx is going to be the profile ID you're looking for.

Hi dhiraj you can get all of your friends username, user id and their profile picture by doing this....https://graph.facebook.com/v2.1/me/taggable_friends?access_token=xxxxx....Hope this helps...and please dont forget to upvote if you identify this as an answer

https://graph.facebook.com/v2.1/me/friends?access_token=xxxxx would return the friends who are using your app i.e., who have authenticated your app...where as https://graph.facebook.com/v2.1/me/taggable_friends?access_token=xxxxx will return all of your friends

I've found if you go to a username's page like:

https://www.facebook.com/username

If you right click on the user's photo, copy the image link you'll get something like :

https://www.facebook.com/photo.php?fbid=12332322&set=a.1afs2&type=3&source=11&referrer_profile_id=100024670088999

The referrer_profile_id is the user's facebook id. Not much help from an API perspective, but gets you the id.

I have also noticed that the JSON from the /me/home node gives user names and their ids from those people who liked anything. Since these people may also be friends, you might be able to partially figure out user ids for friends by looking at this feed in combination with taggable_friends. I am not sure what the Facebook (v2.3) terms of use says in this regard -- so maybe this isn't allowed?

az_

Duplicate: api to get uid from profile URL on facebook

You can call the graph directly as such: https://graph.facebook.com/username where username is the username you want to lookup.

edit: out of date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!