简体   繁体   中英

Error sending facebook request to multiple users IOS

I don't manage to send FB request to multiple users, keeps getting "An error occured, please try again later".

The code looks like this, and it work just fine when only trying to send to a single user.

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

}

Does anyone have a clue how to approach this?

尝试这个

presentRequestsDialogModallyWithSession:[FBSession activeSession]

There where a really stupid mistake causing this. I was storing FB user ids as ints and that's obviously not a good idea since the ids can be really big.

It works just fine if the ids are correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM