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

Is there a way to find out if the user uploaded the image to the profile or has the default Facebook user image via FQL or somthing else?

+5
source share
3 answers

You can use the Python script below (as no programming language is mentioned) to make it work.

urllib.urlopen('https://graph.facebook.com/<PROFILE_ID>/picture?access_token=%s' % access_token).geturl()

This will provide you with the URL of your Facebook profile profile. If this URL contains <PROFILE_ID>, then it loads the image. In addition, the default Facebook image is uploaded.

, :

http://profile.ak.fbcdn.net/hprofile-ak-snc4/195361_<PROFILE_ID>_4179703_q.jpg

:

:

http://b.static.ak.fbcdn.net/rsrc.php/v1/yo/r/UlIqmHJn-SK.gif

:

https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/y9/r/IB7NOFmPw2a.gif

, .

+8

, is_silhouette , "".

:

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

:

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

, PHP:

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;

}
+22

API Facebook, , , , .

, , Facebook JPEG, - GIF. (BTW, ).

GIF URL- ( , URL- CDN, ). , Facebook , , GIF .

PHP- . Facebook, , , .

public static function hasProfilePicture($fbuid) 
{
    /* Really stupid method to test if Facebook user has real profile picture
    * based on Facebook returning a GIF image when you request a large photo.  
    * Use with care - for every profile there an outgoing request! */ 
    $r = get_headers("http://graph.facebook.com/$fbuid/picture?type=square"); 
    return !array_search("Content-Type: image/gif",$r);
}
+3

All Articles