[英]Facebook Graph API for iOS search
I am trying to search places from the GraphAPI using following code without luck. 我试图使用以下代码从GraphAPI搜索位置,没有运气。 Can anybody please enlight my path ? 谁能请我的道路?
If I try to post link/message/photo it works as expected but when trying to get 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.)**
**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];
For "search" you should use "GET" instead of "POST". 对于“搜索”,您应该使用“GET”而不是“POST”。
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
With Facebook iOS SDK, you can use FBRequestConnection after login. 使用Facebook iOS SDK,您可以在登录后使用FBRequestConnection。
[FBRequestConnection startWithGraphPath:@"search?q=coffee&type=place¢er=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);
}
}];
With Last SDK 使用Last 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);
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.