Get profile Facebook API
Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to "Allow" the application)Simply fetch the data through this URL: Show http://graph.facebook.com/userid_here/picture Replace userid_here with id of the user you want to get the photo of. You can also use HTTPS as well. You can use the PHP's file_get_contents function to read that URL and process the retrieved data. Resource: http://developers.facebook.com/docs/api Note: In php.ini, you need to make sure that the OpenSSL extension is enabled to use thefile_get_contents function of PHP to read that URL. To show: 50x50 pixels200 pixels widthTo save (using PHP)NOTE: Don't use this. See @Foreever's comment below. $img = file_get_contents('https://graph.facebook.com/'.$fid.'/picture?type=large'); $file = dirname(__file__).'/avatar/'.$fid.'.jpg'; file_put_contents($file, $img);Where $fid is your user id on Facebook. NOTE: In case of images marked as "18+" you will need a valid access_token from a 18+ user: UPDATE 2015:Graph API v2.0 can't be queried using usernames, you should use userId always. UPDATE: Starting end August 2012, the API has been updated to allow you to retrieve user's profile pictures in varying sizes. Add the optional width and height fields as URL parameters: https://graph.facebook.com/USER_ID/picture?width=WIDTH&height=HEIGHTwhere WIDTH and HEIGHT are your requested dimension values. This will return a profile picture with a minimum size of WIDTH x HEIGHT while trying to preserve the aspect ratio. For example, https://graph.facebook.com/redbull/picture?width=140&height=110returns { "data": { "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c0.19.180.142/s148x148/2624_134501175351_4831452_a.jpg", "width": 148, "height": 117, "is_silhouette": false } }END UPDATE To get a user's profile picture, call https://graph.facebook.com/USER_ID/picturewhere USER_ID can be the user id number or the user name. To get a user profile picture of a specific size, call https://graph.facebook.com/USER_ID/picture?type=SIZEwhere SIZE should be replaced with one of the words square small normal largedepending on the size you want. This call will return a URL to a single image with its size based on your chosen type parameter. For example: https://graph.facebook.com/USER_ID/picture?type=smallreturns a URL to a small version of the image. The API only specifies the maximum size for profile images, not the actual size. Square:
Small
Normal
Large
If you call the default USER_ID/picture you get the square type. CLARIFICATION If you call (as per above example) https://graph.facebook.com/redbull/picture?width=140&height=110it will return a JSON response if you're using one of the Facebook SDKs request methods. Otherwise it will return the image itself. To always retrieve the JSON, add: &redirect=falselike so: https://graph.facebook.com/redbull/picture?width=140&height=110&redirect=false |