Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not Found (404) error for Facebook Graph API/ JavaScript SDK Profile Picture

When trying to access user profile picture from Facebook graph API or JavaScript SDK, the url for picture is returned, but the URL does not resolve to a picture when requested.

The JavaScript SDK returns 404 error, [Link] enter image description here

Note: Yes these profile has a profile picture, I tried with multiple user accounts. (My FaceBook application is not live yet, but all the profiles are added as tester / developer accounts in App roles. So at least I should get a silhouette profile picture according to the limitations mentioned here.

These are the things I tried.

Solutions Tried 01

FB.api(
  '/me',
  { fields: 'id,name,email,picture' },
  (response: { name: string; id: string }) => {
    console.info(response);
  }
);

This API call resolves to a URL like https://z-p3-graph.facebook.com/v18.0/me?access_token= and the response has the picture URL, which doesn't work.

{
    "id": "122098927370045754",
    "name": "John Doe",
    "email": "[email protected]",
    "picture": {
        "data": {
            "height": 50,
            "is_silhouette": false,
            "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=122098927370045754&height=50&width=50&ext=1702101647&hash=AeQk6_WB4RtEAIyWrwI",
            "width": 50
        }
    }
}

Solutions Tried 02

Another way I found on SO was to call the graph.acebook.com directly with access token.

https://graph.facebook.com/122098927370045754?fields=picture.width(720).height(720)&redirect=false&access_token=

Which also gives a URL, but doesn't work.

{
    "picture": {
        "data": {
            "height": 200,
            "is_silhouette": false,
            "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=122098927370045754&height=720&width=720&ext=1702102119&hash=AeQAsmiIwfIfV9vgQ-Y",
            "width": 200
        }
    },
    "id": "122098927370045754"
}

Tried Solution 03

URLs like https://graph.facebook.com/{facebookId}/picture?type=large, as mentioned here only return a silhouette picture, which is understandable because now we need an access token to access these.

But with access token, according to the docs,

https://graph.facebook.com/122098927370045754/picture?type=large&access_token=

It returns the same https://platform-lookaside.fbsbx.com/ URL, which is Not Found.

Am I missing something here? Or It's an issue with FaceBook API itself? Any help would be appreciated.

Edit: Found this thread over at Meta Developers. Still not resolved though. https://developers.facebook.com/community/threads/292690177015780/

Edit 12/27/2023: After our Facebook App was published (Live), the profile images started working. Maybe the unpublished apps are not allowed to access the images.

like image 993
Nishan Avatar asked Jan 30 '26 01:01

Nishan


1 Answers

After our Facebook App was published (Live), the profile images started working, such as this one, which has bit of a lengthier hash (this hash changes each time when the user logs in).

https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=122098927370045754&height=50&width=50&ext=1706283859&hash=AfqHvub2WlgL1CNN6bY__pjilZeRBbzlFzmTsnebKTvUPg

Maybe the unpublished apps are not allowed to access the images.

like image 176
Nishan Avatar answered Feb 03 '26 09:02

Nishan