Reputation: 71101
I know how to get someone's thumbnail via the Facebook API, but how do you get the person's full profile pic? What permissions are necessary to do this?
Upvotes: 0
Views: 1940
Reputation: 390
The full profile picture can not be retrieved via the user's picture connection (https://UID/picture?type=large will only return a picture of about 200x200).
To get the largest version of the profile picture stored on Facebook, you need to access the user's profile photo album. This requires user_photos permission.
The full profile picture can be retrieved by iterating over the albums, looking for the album which has the the type 'profile' and then getting its cover page:
public function getProfilePictureMaxUrl($facebook,$uid,$userAccessToken) {
$params = array('access_token' => $userAccessToken);
$r = $facebook->api('/'.$uid.'/albums',$params);
foreach ($r['data'] as $album) {
if ($album['type'] == 'profile') {
//retrieve information about this album
$r = $facebook->api('/'.$album['id'],$params);
$pid = ($r['cover_photo']);
//retrieve information about this photo
$r = $facebook->api('/'.$pid,$params);
return $r['source'];
}
}
//Profile folder not found (could be because of paging)
error_log('Failed to retrieve profile folder for uid '.$uid);
return false;
}
Upvotes: 1
Reputation: 3544
Append type=large
to the query string. For example https://graph.facebook.com/100/picture?type=large
Upvotes: 4