0

I am trying to get the user's current profile photo...

can anyone assist over here?

thanks !!

Yoni
  • 553
  • 3
  • 14
  • 24
  • possible duplicate of [Facebook API - How do I get a facebook user's profile image through the FB api (without requiring the user to Allow app)](http://stackoverflow.com/questions/2821061/facebook-api-how-do-i-get-a-facebook-users-profile-image-through-the-fb-api-w) – Sebastian Paaske Tørholm Feb 09 '11 at 19:10
  • possible duplicate of [How can I display the users profile pic using the facebook graph api?](http://stackoverflow.com/questions/3012905/how-can-i-display-the-users-profile-pic-using-the-facebook-graph-api) – ifaour Feb 09 '11 at 21:39

3 Answers3

4

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

Piva
  • 982
  • 6
  • 13
4
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 
Tim Stone
  • 19,119
  • 6
  • 56
  • 66
meAtStackOverflow
  • 87
  • 1
  • 3
  • 11
0

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>