简体   繁体   中英

How Can I get the facebook user id in order to get profile picture?

I just want to put a facebook user profile picture in a simple webpage.

I have read a lot about this, and I found the same answer, "Facebook Api 2.2" cannot query users by username:

http://graph.facebook.com/username 

just by user id, but How Can I do this without the api?, I also read that I have to make the user sign into facebook account in order to get the user id, something like that, but it's just a simple webpage.

I was trying to do this in php.

//this is just for showing the page

$homepage = file_get_contents('https://www.facebook.com/ricardo.citerio');
var_dump($homepage);

Here my idea was to get the page and search for this keyword "fb://profile" in the code and catch the first X characters from that point:

fb://profile/621673493 


//I can get this by opening the source code of 
https://www.facebook.com/ricardo.citerio  

but the big issue is that file_get_contents goes to the index page "www.facebook.com" not to "www.facebook.com/username", with any other page works fine but not with facebook.

You can't and shouldn't do it without the API. You must authenticate users in order to use their data. Please read Facebook Platform Policies here: https://developers.facebook.com/policy/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM