Facebook graph user picture won't show on mobile devices

前端 未结 3 2018
谎友^
谎友^ 2020-11-28 13:25

I use the url https://graph.facebook.com/{app_user_id}/picture?width=120&height=120 to show the user picture on my app, but since this morning, it has stopp

相关标签:
3条回答
  • 2020-11-28 14:11

    Though I didn't find any official announcements, Facebook during last few days changed their api's, now when you request user's public profile the picture url has extra parameters, ext and hash

    Calling the url without these params returns 404 error.

    Not sure if the change is affecting Page Scope ID's only.

    Currently, when you request user's public profile data the url looks like this https://lookaside.facebook.com/platform/profilepic/?psid=PAGE_SCOPED_ID&height=1024&ext=1522585606&hash=AeThc8c7EQDFgShs

    before it was just

    https://lookaside.facebook.com/platform/profilepic/?psid=PAGE_SCOPED_ID&height=1024

    It seems to me the only known solution currently would be requesting new public profile data and updating your database.

    Hope that helps.

    0 讨论(0)
  • 2020-11-28 14:25

    This seems to be a bug. Started happening to my app earlier on this morning. Still no fix as of yet.

    A few bug reports that have been submitted on Facebook for Developers:

    1. Profile Pictures Can't Load
    2. Graph API Profile picture doesn`t work on mobile
    3. Cross site policy error while accessing graph pictures
    0 讨论(0)
  • 2020-11-28 14:26

    I faced the same issue today and I'v found a solution for that and it worked for me.

    After login we get below Profile pic URL

    http://graph.facebook.com/11111111111/picture?type=large&height=320&width=420
    

    11111111111 is your social id/facebook id

    now we need to change this URL in order to display image, here is the code.

    try {
         profile_pic = new URL("https://graph.facebook.com/" + id + "/picture?type=large");
         Log.i("profile_pic", profile_pic + "");
         Picasso.with(getContext()).
         load(profile_pic.toString())
         .placeholder(R.drawable.img)
         .into(imageviewId);
         }
    catch (MalformedURLException e) {
           e.printStackTrace();
        }
    

    id is your socialid/facebook id

    in short we just need to remove &height=320&width=420 from url.

    you can compare both the url:

    http://graph.facebook.com/11111111111/picture?type=large&height=320&width=420
    
    https://graph.facebook.com/11111111111/picture?type=large
    

    and yes you need to change http to https as well

    0 讨论(0)
提交回复
热议问题