向多个用户IOS发送Facebook请求时出错

时间:2013-03-29 15:02:26

标签: iphone ios6 facebook-ios-sdk

我无法向多个用户发送FB请求,不断收到“发生错误,请稍后再试”。

代码看起来像这样,只有在尝试发送给单个用户时才能正常工作。

- (void)sendRequest:(NSArray *) targeted {

NSMutableDictionary* params =
[[NSMutableDictionary alloc]init];

if (targeted != nil && [targeted count] > 0) {
    NSString *selectIDsStr = [targeted componentsJoinedByString:@","];
    [params setObject:selectIDsStr forKey:@"to"];
}

// Display the requests dialog
[FBWebDialogs
 presentRequestsDialogModallyWithSession:nil
 message:@"Learn how to make your iOS apps social."
 title:nil
 parameters:params
 handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
     if (error) {
         // Error launching the dialog or sending request.
         NSLog(@"Error sending request.");
     } else {
         if (result == FBWebDialogResultDialogNotCompleted) {
             // User clicked the "x" icon
             NSLog(@"User canceled request.");
         } else {
             // Handle the send request callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"request"]) {
                 // User clicked the Cancel button
                 NSLog(@"User canceled request.");
             } else {
                 // User clicked the Send button
                 NSString *requestID = [urlParams valueForKey:@"request"];
                 NSLog(@"Request ID: %@", requestID);
             }
         }
     }
 }];

}

有没有人知道如何处理这个问题?

2 个答案:

答案 0 :(得分:0)

试试这个

presentRequestsDialogModallyWithSession:[FBSession activeSession]

答案 1 :(得分:0)

导致这个真正愚蠢的错误。我将FB用户id存储为int,这显然不是一个好主意,因为id可能非常大。

如果ID正确,它就可以正常工作。