Facebook graph user picture won't show on mobile devices

前端 未结 3 2027
谎友^
谎友^ 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: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

提交回复
热议问题