2012-01-27 4 views
4

다음 코드를 사용하여 GraphAPI에서 장소를 검색하려고합니다. 아무도 내 길을 밝힐 수 없습니까?iOS 검색 용 페이스 북 그래프 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을 facebook에서 github의 그래프 api 용으로 다운로드했으며 동일한 샘플 코드를 포함합니다.

1

"검색"의 경우 "POST"대신 "GET"을 사용해야합니다. 페이스 북 아이폰 OS 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); 
    }]; 
관련 문제