2016-05-29 3 views
0

私のアプリでは、他のユーザーが自分のプロフィールにアクセスしたときに、自分のユーザーのFacebookカバー写真を表示しようとしています。Facebookの写真を取得すると、画像のソースなしでJSONが返される

問題は時々エラーがありますが、JSONレスポンスにはカバー写真のソースが含まれていないことがほとんどです。必要な許可があるのか​​、何が間違っているのでしょうか?

応答:私はFBのドキュメントのように、カバー写真を取得するために使用

FB Response:{Response: responseCode: 200, graphObject: {"id":"1159287107464088"}, error: null}

は方法:

FacebookSdk.sdkInitialize(this.getApplicationContext(), new FacebookSdk.InitializeCallback() { 
      @Override 
      public void onInitialized() { 
       accessToken = AccessToken.getCurrentAccessToken(); 

       if (accessToken != null) { 
        Bundle params = new Bundle(); 
        params.putString("fields", "cover"); 
        new GraphRequest(
          AccessToken.getCurrentAccessToken(), 
          "other_users_fbId", 
          params, 
          HttpMethod.GET, 
          new GraphRequest.Callback() { 
           public void onCompleted(GraphResponse response) { 

            FacebookRequestError error = response.getError(); 

            if (error != null) { 
             http.sendIssueToServer("error: " + 
               error.getErrorMessage()); 

            } else { 

             try { 
              Log.i("LoginActivity", response.toString()); 
              JSONObject obj = response.getJSONObject(); 

              JSONObject cover = obj.getJSONObject("cover"); 
              String src = cover.getString("source"); 
              imageLoader.displayImage(src, coverIv); 

             } catch (Exception e) { 
              e.printStackTrace(); 
              http.sendIssueToServer("FB Response:" + response.toString()); 
             } 
            } 
           } 
          } 

        ).executeAsync(); 
       } 

      } 
     }); 
+0

あなたはJSONを共有することはできますか? –

答えて

0

あなたが任意の許可、認可の唯一のAppスコープIDは必要ありません。ユーザー - または/meを使用してください。 JSONは、この(/me?fields=cover)のようになります。それは時々このように見えない場合は

{ 
    "cover": { 
    "id": "xxx", 
    "offset_y": 0, 
    "source": "https://scontent.xx.fbcdn.net/..." 
    }, 
    "id": "xxx" 
} 

、必ずユーザーがカバー写真を持っているか、バグを報告していますhttps://developers.facebook.com/bugs/

+0

ありがとう、確かに、ユーザーがカバー写真を持っていなかったときだけ問題が現れました:) –

関連する問題