2016-04-22 11 views
0

Facebook Graph APIからデータを取得するために以下のコードを使用しています。私はグラフAPI Explorerで動作する、次の検索クエリを使用する場合Facebook Graph API Androidでの検索

GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken() 
         , "/me" 
         , new GraphRequest.Callback() { 
          @Override 
          public void onCompleted(GraphResponse response) { 
           showToast(response.toString()); 
           ((TextView) findViewById(R.id.result_textview)).setText(response.toString()); 
          } 
         }).executeAsync(); 

しかし、それはもう動作しません。

GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken() 
         , "https://stackoverflow.com/search?q=coffee&type=place" 
         , new GraphRequest.Callback() { 
          @Override 
          public void onCompleted(GraphResponse response) { 
           showToast(response.toString()); 
           ((TextView) findViewById(R.id.result_textview)).setText(response.toString()); 
          } 
         }).executeAsync(); 

エラーjsonは以下のとおりです。

Response:responseCode:400, 
graphObject:null, 
error:{ 
    HttpStatus:400, 
    errorCode:100, 
    errorType:GraphMethodException, 
    errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api 
} 
} 
+0

何をしようとしていますか?なぜこのグラフのapiノードを使用していますか? –

+0

場所を検索しようとしています。 – myatmins

答えて

2

ドキュメントをお読みください。あなたは間違ったやり方をしています。

new GraphRequest(
    AccessToken.getCurrentAccessToken(), 
    "...?fields={fieldname_of_type_Location}", 
    null, 
    HttpMethod.GET, 
    new GraphRequest.Callback() { 
     public void onCompleted(GraphResponse response) { 
      /* handle the result */ 
     } 
    } 
).executeAsync() 

か、フィールドに

GraphRequest request = GraphRequest.newGraphPathRequest(
    accessToken, 
    "/search", 
    new GraphRequest.Callback() { 
    @Override 
    public void onCompleted(GraphResponse response) { 
     // Insert your code here 
    } 
}); 

Bundle parameters = new Bundle(); 
parameters.putString("type", "place"); 
parameters.putString("center", "53,27"); 
parameters.putString("distance", "30000"); 
request.setParameters(parameters); 
request.executeAsync(); 

現在地などを引用し、国、経度、緯度を使用することができ、これはあなたのために役立つだろうdocs

希望はあります。

+0

私はこれをやろうとしています。 https://developers.facebook.com/docs/graph-api/using-graph-api#search – myatmins

+0

これがうまく動作しない場合は、私に知らせてくださいこの答えを試してください。しかし、有効なクエリ –

+0

を追加して、「コーヒー」を検索するにはどうすればよいのでしょうか。 – myatmins