2013-03-29 55 views
2

我無法將FB請求發送給多個用戶,不斷收到「發生錯誤,請稍後再試」。向多個用戶發送facebook請求時出錯IOS

該代碼看起來像這樣,並且只在嘗試發送給單個用戶時工作得很好。

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

}

有沒有人有一個線索如何處理呢?

+0

好像我試圖向其中一個用戶發送請求時出現了問題。 – johan

回答

0

有一個非常愚蠢的錯誤造成這個地方。我將FB用戶ID存儲爲整數,這顯然不是一個好主意,因爲ID可以非常大。

它工作得很好,如果ID是正確的。

0

試試這個

presentRequestsDialogModallyWithSession:[FBSession activeSession]