简体   繁体   中英

Failed to load Facebook Graph API profile picture URL

So this code was working fine for me before:

    FB.api("/me/picture?width=600&height=600", function(profile_picture)
    {
            user_me_picture = profile_picture.data.url;
    }

But after Facebook Dev update, the url parameter can't be loaded, it's because of new Facebook link on the Graph API:

{
  "data": {
    "height": 50,
    "is_silhouette": false,
    "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=1633647180278779&height=50&width=50&ext=1531277613&hash=AeTrVjn5tUK7zxEo",
    "width": 50
  }
}

Is there anyway I can fix my code with this new Facebook profile picture url?

Thank you!

I know it's probably late, but this happened to me recently without a warning. Suddenly, my app stopped to load the user's profile picture.

After research a bit, i found out that, from now on, you need to call to the Facebook's API directly to download it.

Check this answers if you want to figure out of the "why of this" and how to fix it in depth, but in short, just add the Facebook's user id into the URI of the API like this:

https://graph.facebook.com/{userId}/picture where userId is the one returned by Facebook in the same API call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM