2012-01-27 10 views
4

私は幸運なことに次のコードを使ってGraphAPIから場所を検索しようとしています。誰も私の道を踏み入れることができますか?iOSの検索のためのFacebook Graph API

気にしない私は、リンク/メッセージ/写真を投稿しようとすると期待どおりに動作しますが、場所を取得しようとしたとき、それは常に失敗し、私に**The operation couldn’t be completed. (facebookErrDomain error 10000.)**

//Following statement is using permissions 
NSArray * permissions = [NSArray arrayWithObjects:@"publish_stream",@"user_checkins", @"friends_checkins", @"publish_checkins", nil]; 

[facebook authorize:FB_APP_ID permissions:permissions delegate:_delegate]; 
NSString *centerString = [NSString stringWithFormat: @"%f,%f", 37.76,-122.427]; 


     NSString *graphPath = @"search"; 
     NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
             @"coffee",@"q", 
             @"place",@"type", 
             centerString,@"center", 
             @"1000",@"distance", // In Meters (1000m = 0.62mi) 
             nil]; 

[facebook requestWithGraphPath:_path andParams:_params andHttpMethod:@"POST" andDelegate:_delegate]; 

答えて

3

を与えます。最新のサンプルHackBookをgithubのグラフapiのfacebookからダウンロードし、同じサンプルコードを含んでいます。

1

"検索"には、 "POST"の代わりに "GET"を使用する必要があります。 FacebookのiOSのSDKで

https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search

は、ログイン後FBRequestConnectionを使用することができます。

最終SDKで
[FBRequestConnection startWithGraphPath:@"search?q=coffee&type=place&center=37.76,-122.427&distance=1000" 
          completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
           if (!error) { 
            // Sucess! Include your code to handle the results here 
            NSLog(@"result: %@", result); 

           } else { 
            // An error occurred, we need to handle the error 
            // See: https://developers.facebook.com/docs/ios/errors 
            NSLog(@"error: %@", error); 
           } 
          }]; 
0

NSMutableDictionary *params2 = [NSMutableDictionary dictionaryWithCapacity:3L]; 

    [params2 setObject:@"37.416382,-122.152659" forKey:@"center"]; 
    [params2 setObject:@"place" forKey:@"type"]; 
    [params2 setObject:@"1000" forKey:@"distance"]; 

    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/search" parameters:params2 HTTPMethod:@"GET"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
     NSLog(@"RESPONSE!!! /search"); 
     NSLog(@"result %@",result); 
     NSLog(@"error %@",error); 
    }];