How to show facebook and twitter user profile picture on my site comments

I display a Gravatar Avatar on my webpages comments

like

$hash = md5(trim($row['email'])); $default_usr = urlencode('http://localhost/example/images/user-icon.jpg'); src=\"http://www.gravatar.com/avatar/$hash.'.jpg?s=45&d=$default_usr'\" 

but I want it to be like an avatar, when someone posted a comment on my site using the email address that belong to his facebook or twitter account, his image is also displayed on my comments on the site.

But I dont know how?

Any Facebook lover or Twitter lover who can help me. Please, please. I do not want to use the facebook application. I am developing my own comment widget using php where I want to use it.

+4
source share
1 answer

http://graph.facebook.com/paul.knox.anthony/picture

will provide you with a user profile picture from the Facebook Charts API. file_get_contents () with PHP should allow you to capture this. However, it looks like you only have the user's email address. In this case, you need authorization from Facebook in order to get only the email address from the user.

See: Is there a way to get the email id of a user after checking his / her Twitter id with OAuth?

Facebook API. How to get Facebook user profile picture via Facebook API (without the need to use the "Allow" application)

You will most likely have to do some OAuth stuff.

+4
source

Source: https://habr.com/ru/post/1387639/


All Articles