how to show facebook and twitter user profile image on my website's comments

user1008545 picture user1008545 · Dec 22, 2011 · Viewed 8.5k times · Source

I am showing Gravatar's Avatar on my webpage comments

like that

$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 that as avatar's when someone post a comment on my website using an email which belong to its facebook account or twitter account his/her 's image shows on my website's comments too.

But i don't know how?

Any Facebook Lover or twitter lover who can help me Please Please.
I do not want to use facebook app i am developing my own comment widget using php where i want to use it

Answer

Squiggs. picture Squiggs. · Dec 22, 2011

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

will get you the profile picture of a user from the Facebook graph API. file_get_contents() with PHP should allow you to grab that. However, it looks like you only have the email address of the user. In that case, you'll need authorisation from Facebook to get the user from just an email address.

See: Is there a way to get an user's email ID after verifying his/her Twitter identity using OAuth?

Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to "Allow" the application)

You are most likely going to have to do some OAuth stuff.