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

1

15

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.

Daugherty answered 9/11, 2023 at 7:13 Comment(2)
Running into the same issue. Did you ever find a solution?Presentative
@Presentative After publishing our application (a.k.a going live) the profile images started showing up as expected.Daugherty
D
3

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.

Daugherty answered 27/12, 2023 at 15:48 Comment(1)
That's an interesting theory, and it could explain a lot. Can someone here confirm if profile images indeed start functioning correctly after the app is published? Additionally, it would be great if anyone could find official documentation clarifying this behavior. Any insights would be really valuable.Pollack

© 2022 - 2024 — McMap. All rights reserved.