I can't load images from Graph Facebook

后端 未结 4 2081
鱼传尺愫
鱼传尺愫 2021-02-10 03:41

url: https://graph.facebook.com/100779423975829/picture?type=large;

other url with type normal: https://graph.facebook.com/100779423975829/picture?type=normal


4条回答
  •  一个人的身影
    2021-02-10 04:30

    Yes, the redirections from http:// to https:// protocols hinders the downloading using Picasso,Glide ets. You may go ahead with following two approaches:

    1. SimpleDraweeView from Facebook Sdk. It handles the redirection internally.

    2. Make a graph request to fetch the re-directed url like below and use that url in picasso.

      new GraphRequest(AccessToken.getCurrentAccessToken(), "/"+fbUserId+"/picture?width="+width+"&height="+height+"&redirect=false", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) {

                          try {
                              String url = response.getJSONObject().getJSONObject("data").getString("url");
                              loadFacebookProfilePicInImageView(url);
                          } catch (Exception e) {
                              e.printStackTrace();
                          }
      
                      }
                  }
          ).executeAsync();
      

提交回复
热议问题