How to determine if a Facebook user has uploaded a profile picture or its default?

amirash picture amirash · Apr 5, 2011 · Viewed 11k times · Source

Is there a way to know if a user uploaded an image to the profile or it has the default user picture of Facebook via FQL or somthing else?

Answer

Adam picture Adam · Feb 12, 2013

If a user doesn't have a photo then the is_silhouette field will be true when you request the user object with the "photo" field specified.

Example request:

https://graph.facebook.com/username?fields=picture

Response:

{
   "id": "100002095576350",
   "picture": {
      "data": {
         "url": "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif",
         "is_silhouette": true
      }
   }
}

Quick, dirty PHP function:

function facebook_user_has_photo($username_or_id){

        $request = file_get_contents('https://graph.facebook.com/'.$username_or_id.'?fields=picture');

        if($request):

            $user = json_decode($request);

            if($user && !$user->picture->data->is_silhouette) return true;

        endif;

        return false;

}