Reputation: 289
What is the correct way of verifying that a user has put in a facebook profile picture (ie the non-default one), and if so, to retrieve it?
This: How to determine if a Facebook user has uploaded a profile picture or its default? talks about a method, but the author himself says that its a bad method:
public static function hasProfilePicture($fbuid)
{
/* Really stupid method to test if Facebook user has real profile picture
* based on FB returning a gif when you request a large photo.
* Use with care - for every profile there's an outgoing request! */
$r = get_headers("http://graph.facebook.com/$fbuid/picture?type=square");
return !array_search("Content-Type: image/gif",$r);
}
Upvotes: 1
Views: 953
Reputation: 5416
If a user HAS a profile photo, it can be accessed via http://graph.facebook.com/<facebook username>/picture
. For example, http://graph.facebook.com/gauravgupta.in/picture redirects to a specific URL and shows my Facebook profile picture.
However, if a user does NOT have a profile picture, the above URL gets redirected to the URL of the standard placeholder image, which is currently http://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/yo/r/UlIqmHJn-SK.gif
It's definitely not a reliable way, but will work till Facebook decides to change it.
Upvotes: 1