Facebook Graph API for iOS Search

I am trying to search for places from GraphAPI using the following code with no luck. Can anyone tell me about my path?

If I try to post a link / message / photo, it works as expected, but when I try to get the location, it always fails and gives me **The operation couldn't be completed. (facebookErrDomain error 10000.)** **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]; 
+4
source share
3 answers

Nothing. We downloaded the latest HackBook sample from facebook for the api chart from github and it contains sample code for it.

+3
source

To "search" you must use "GET" instead of "POST".

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

Using the Facebook iOS SDK, you can use the FBRequestConnection after logging in.

  [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); } }]; 
+1
source

With the latest SDK

 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); }]; 
0
source

Source: https://habr.com/ru/post/1393311/


All Articles