I am trying开发者_开发问答 to get the user's current profile photo...
can anyone assist over here?
thanks !!
Not specific to PHP, but the user's profile picture is public, so if you have the users facebook ID, just request:
http://graph.facebook.com/user-id/picture
More info on: http://developers.facebook.com/docs/reference/api
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$updated = date("l, F j, Y", strtotime($me['updated_time']));
echo "Hello " . $me['name'] . "<br />";
echo "You last updated your profile on " . $updated . "<br />" ;
echo "<img src='https://graph.facebook.com/".$uid."/picture'/>";
}//end try getUser
catch (FacebookApiException $e) {
echo "Error:" . print_r($e, true);
}//end catch getUser
I wrote this library a few months ago.
All you need is the user's email address, if it's public, it will fetch his profile picture.
It's super easy to use, you can grab it from here...
https://github.com/shlomnissan/profilepicgrabber
<?php
require '../src/profilepicgrabber.php';
$pic_grabber = new ProfilePicGrabber('contact@snissan.me');
?>
<h3>Facebook: </h3>
<p><img src="<?php echo $pic_grabber->facebook(); ?>" /></p>
精彩评论