通过FB邀请朋友在Ios中自己申请
问题描述:
我正在iPhone上开发一个应用程序,我需要邀请朋友加入我的应用程序,通过使用图形API在FB上发送消息,我也希望当用户点击邀请FB的朋友时那么我的应用程序显示对话框实际上是FB对话框,其中显示了他的所有朋友,并且用户可以选择想要发送消息的朋友。由于通过FB邀请朋友在Ios中自己申请
答
使用@ “facebook.events.invite” 的方法来邀请你的朋友从iPhone
如
params = [NSDictionary dictionaryWithObjectsAndKeys:facebookEventString,@"eid",udidsString,@"uids",nil];
[[FBRequest requestWithDelegate:self] call:@"facebook.events.invite" params:params];
答
您可以通过使用无摩擦的要求如下做到这一点
NSString *to =[NSString stringWithFormat:@"%d",[[[FriendUIDArray
objectAtIndex:index]
objectForKey:@"uid"] intValue]];
FBFrictionlessRecipientCache *friendCache =
[[FBFrictionlessRecipientCache alloc] init]; [friendCache
prefetchAndCacheForSession:nil];
NSMutableDictionary* params = [NSMutableDictionary
dictionaryWithObjectsAndKeys:
to, @"to",
nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:@"I’m using Nightup to find great party's
around me."] title:nil parameters:params handler:^(FBWebDialogResult result,
NSURL *resultURL, NSError *error)
{
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(@"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(@"User canceled request.");
} else {
NSLog(@"Request Sent.");
}
}}
friendCache:friendCache];
如果你没有你想邀请的特定朋友的UID,那么按照这个方法,你可以在对话框中选择朋友。
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:@"I just smashed %d friends! Can you beat it?", nScore]
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(@"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(@"User canceled request.");
} else {
NSLog(@"Request Sent.");
}
}}];
你可以找到更多的细节here
我已经知道这样的想法,但是这不是我想要的,怎么我需要FB对话框,用户选择特定的他的朋友。 – Aleem 2012-01-18 13:44:27