Facebook的图形API为iOS搜索

问题描述:

我想从GraphAPI使用下面的代码没有运气搜索的地方。任何人都可以照亮我的道路吗?Facebook的图形API为iOS搜索

如果我尝试发布链接/消息/照片它按预期工作,但试图获得位置时,它总是失败,给我**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]; 

没关系。从facebook上下载最新的示例HackBook来自github的图形api,它包括相同的示例代码。

对于“搜索”,您应该使用“GET”而不是“POST”。

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

与Facebook的iOS SDK,您可以登录后使用FBRequestConnection。

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

与去年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); 
    }];