使用FBWebDialogs通过iPhone App邀请Facebook好友

时间:2014-06-21 18:35:25

标签: iphone facebook facebook-graph-api ios7

我使用Facebook sdk 3.10使用FBWebDialogs一次向多个朋友发送请求。以下代码我正在使用,所有事情都很好,就像选择多个朋友一样,向他们发送请求。但是有一个问题,就是这个FBWebDialogs使用了一些朋友的限制,因为我有300多个朋友,但这总是只显示12-15个朋友。

CODE

[FBWebDialogs
             presentRequestsDialogModallyWithSession:nil
             message:@"Learn how to make your iOS apps social."
             title:nil
             parameters:nil
             handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                 if (error) {
                     // Error launching the dialog or sending the 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);
                         }
                     }
                 }
             }];

使用上面我在对话框中只能看到最多12位朋友?我错过了什么吗?

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

您应该将NSDictionary类型对象传递给参数参数。 您可以这样创建:

NSArray *suggestedFriends = [[NSArray alloc] initWithObjects:@"fb_id1", @"fb_id2", nil];

NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:[suggestedFriends componentsJoinedByString:@","], @"suggestions", nil];

现在

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

这里将显示所有建议的Facebook ID的朋友。