Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过Facebook邀请朋友使用我的ios应用程序_Ios_Facebook_Facebook Graph Api - Fatal编程技术网

通过Facebook邀请朋友使用我的ios应用程序

通过Facebook邀请朋友使用我的ios应用程序,ios,facebook,facebook-graph-api,Ios,Facebook,Facebook Graph Api,我刚刚开始一个现有的项目,我应该在其中添加功能,邀请你的Facebook好友使用该应用程序。它使用Parse的PFFacebookUtils进行连接,我尝试使用Facebook API获取您的整个好友列表,以便您可以选择他们并邀请他们下载和使用该应用程序 因为v2api,这是可能的吗?据我所知,你只能得到一个已经使用过该应用程序的朋友列表(无用),或者你可以得到一个“不可侵犯的朋友”列表,但前提是它是一个Facebook画布游戏,而这个应用程序不是。我认为通过Facebook邀请人们使用你的应用

我刚刚开始一个现有的项目,我应该在其中添加功能,邀请你的Facebook好友使用该应用程序。它使用Parse的PFFacebookUtils进行连接,我尝试使用Facebook API获取您的整个好友列表,以便您可以选择他们并邀请他们下载和使用该应用程序

因为v2api,这是可能的吗?据我所知,你只能得到一个已经使用过该应用程序的朋友列表(无用),或者你可以得到一个“不可侵犯的朋友”列表,但前提是它是一个Facebook画布游戏,而这个应用程序不是。我认为通过Facebook邀请人们使用你的应用程序是一种非常常见的功能,但Facebook是否不赞成这种功能?我希望有人知道一些我不知道的事情,有一种方法可以做到这一点


提前谢谢

您应该仍然能够使用“请求”对话框(该对话框允许用户选择向谁发送请求),而无需特殊权限

只有当您正在构建自己的界面并且需要枚举用户可以向哪些用户发送请求时,才需要invitable friends API,请求对话框本身在没有该API的情况下仍然可以工作

此处提供了使用“请求”对话框的文档 特定于iOS的教程有一个使用示例,其中介绍了几个使用案例:
更多参考文档:

您应该使用Facebook GameRequest。 它完全由Facebook控制,您无需实施任何操作。您可以指定一些属性(例如请求的消息、标题、筛选器、其他数据,这些数据可在受邀请的用户安装您的应用程序时使用),等等。您还可以实现一个委托类,并获取有关成功或失败、邀请了多少朋友等信息

一些基本的iOS用法,例如:

FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
    gameRequestContent.message = @"Please come play <you_game> with me!";
    gameRequestContent.title = @"INVITE FRIENDS TO PLAY <your_game>";
    gameRequestContent.data = "some_extra_data_on_this_request"
    gameRequestContent.filters = FBSDKGameRequestFilterAppNonUsers; // filter says that only Non-App users will appear in the list

// implement delegate as well:
    MyGameRequestDialogDelegate* myGameRequestDialogDelegate = [[ MyGameRequestDialogDelegate alloc] init];

// show the game request dialog
    [FBSDKGameRequestDialog showWithContent:gameRequestContent delegate:myGameRequestDialogDelegate];
FBSDKGameRequestContent*gameRequestContent=[[FBSDKGameRequestContent alloc]init];
gameRequestContent.message=@“请和我一起玩吧!”;
gameRequestContent.title=@“邀请朋友玩”;
gameRequestContent.data=“此请求上的一些额外数据”
gameRequestContent.filters=FBSDKGameRequestFilterAppNonUsers;//筛选器表示只有非应用程序用户才会出现在列表中
//同时执行以下任务:
MyGameRequestDialogDelegate*MyGameRequestDialogDelegate=[[MyGameRequestDialogDelegate alloc]init];
//显示游戏请求对话框
[FBSDKGameRequestDialog showWithContent:gameRequestContent委托:myGameRequestDialogDelegate];
委托类:

@interface MyGameRequestDialogDelegate : NSObject < FBSDKGameRequestDialogDelegate >    

@end

@implementation MyGameRequestDialogDelegate

 - (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didCompleteWithResults:(NSDictionary *)results
 {
    NSLog(@"FBSDKGameRequest Success");

    NSArray* arr = [results objectForKey:@"to"];
    if (arr)
    {
       // get number of invited friends
       unsigned long count = [arr count];
    }
}

- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog
{
    NSLog(@"FBSDKGameRequest User Cancelled");
}

- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
         didFailWithError:(NSError *)error
{
    NSLog(@"FBSDKGameRequest Error: %@", error);
}
@interface MyGameRequestDialogDelegate:NSObject
@结束
@实现MyGameRequestDialogDelegate
-(void)gameRequestDialog:(FBSDKGameRequestDialog*)gameRequestDialog未完成结果:(NSDictionary*)结果
{
NSLog(@“FBSDKGameRequest Success”);
NSArray*arr=[results objectForKey:@“to”];
如果(arr)
{
//获取受邀请朋友的数量
无符号长计数=[arr计数];
}
}
-(void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog*)gameRequestDialog
{
NSLog(@“FBSDKGameRequest用户已取消”);
}
-(void)gameRequestDialog:(FBSDKGameRequestDialog*)gameRequestDialog
didFailWithError:(n错误*)错误
{
NSLog(@“FBSDKGameRequest错误:%@”,错误);
}
有关完整文档,请参阅: