facebook oauth, no picture with basic permissions

I'm using oauth to log facebook users in to my app. I'm testing with my FB account and with the basic permissions scope. Facebook docs say that I should be able to get 'picture' with basic permissions, but my account has no 'picture' property when I access it with the API. First name, last name, etc. are there though.

Is this because my account is not publicly viewable? Why might this happen? I definitely have a profile picture attached.

Here's my fb link: http://www.facebook.com/josh.nankin

Answers


best way is to keep the basic permissions and fire the request for the image in a separate step. Ask the graph api in this way:

https://graph.facebook.com/[fb_user_id]?fields=picture.type(small)

larger image:

https://graph.facebook.com/[fb_user_id]?fields=picture.type(large)

You will get a JSON response like:

{
   "id": "100001XXXXXXXXX",
   "picture": {
      "data": {
         "url": "http://profile.ak.fbcdn.net/hprofile-XXXX/41524_1000018XXX51507_XXXX3_q.jpg",
         "is_silhouette": false
      }
   }
}

You can derive the profile photo URL directly from the basic standard OAuth info returned from facebook as Josh Nankin noted, BUT with a clarification.

You can still use the user's ID returned to request the photo, for example:

https://graph.facebook.com/914431778578699/picture?type=large

is the same as

https://graph.facebook.com/dark.eye.1/picture?type=large

This way only one request must be made, because you can interpolate the photo URL as you store it in the DB.


https://developers.facebook.com/docs/reference/api/user/:

“picture: The URL of the user's profile pic (only returned if you explicitly specify a 'fields=picture' param)”

You haven’t probably overlooked the part marked in bold …?


So, still not sure why the graph api does not return a picture property when you hit the /me path on the API, but once you have the username from /me, you can get the picture pretty easily at:

https://graph.facebook.com/USERNAME/picture


Actually you don't need to allow public access to get the profile picture since you can get the USER_ID. Though the USER_ID you can navigate to the profile picture easily.

function checkLoginState() {
    FB.getLoginStatus(function(response) {
        statusChangeCallback(response);
        console.log('Welcome!  Fetching your information.... ');
        var url = '/me?fields=id,name';
        FB.api(url, function(response) {
             var linkpp = 'https://graph.facebook.com/' + response.id + '/picture?type=large';
             document.getElementById("id_of_link_tag").href = linkpp;
        });
    });
}

You can change the type in variable linkpp to type=small which returns a low resolution image.

var linkpp = 'https://graph.facebook.com/' + response.id + '/picture?type=small';

Need Your Help

How to use php json_encode options in twig file with json_encode twig function

php symfony twig

I am trying to use twig json_encode function but when I do this