我在我的应用中使用Facebook sdk。有一个屏幕,我想发送邀请给我的Facebook好友加入我的应用程序。我正在使用以下代码执行此操作并在其中设置参数“app_non_users”,以便在我的所有朋友中,我希望那些未授权我的应用程序的人。这段代码对我来说很好。
SBJSON *jsonWriter = [SBJSON new];
NSArray *filters = [NSArray arrayWithObject:@"app_non_users"];
NSString *filtersString = [jsonWriter stringWithObject:filters];
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
@"invite", @"message",
@"Check this out", @"notification_text",
filtersString, @"filters",
@"Invite Friends", @"title",
nil];
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:@"App Invite"
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.");
[self actionBack:nil];
} 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.");
[self actionBack:nil];
} else {
// User clicked the Send button
NSString *requestID = [urlParams valueForKey:@"request"];
NSLog(@"Request ID: %@", requestID);
NSLog(@"%@",resultURL);
}
}
}
}];
我得到了成功的回应,
fbconnect://success?request=1530223140578996&to%5B0%5D=398672303626018
我从上面的回复中提取了“to”id,在上面的例子中是“398672303626018”,但这不是我邀请的那个用户的实际Facebook用户ID。实际上他的Facebook就是这个“100004497541090”。所以我的问题是如何获得之前未授权我的应用程序的受邀用户的Facebook用户ID。 提前谢谢!