[英]Facebook iOS SDK - Sending a facebook user an app request
我试图通过Facebook使用facebook iOS SDK发送应用程序请求,我使用以下代码:
NSString *message = [[NSString alloc] initWithFormat:@"blah blah blah"];
NSString *data = [[NSString alloc] initWithFormat:@"blah blah blah"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", data, @"data", nil];
[_facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/apprequests",userID] andParams:params andHttpMethod:@"POST" andDelegate:self];
[message release];
[data release];
这给了我以下错误:
Error: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x788c5b0 {error=<CFBasicHash 0x788c080 [0x1bf53e0]>{type = mutable dict, count = 2,
entries =>
2 : <CFString 0x788b560 [0x1bf53e0]>{contents = "type"} = <CFString 0x788c3f0 [0x1bf53e0]>{contents = "OAuthException"}
3 : <CFString 0x788c560 [0x1bf53e0]>{contents = "message"} = <CFString 0x788c480 [0x1bf53e0]>{contents = "(#200) Invalid Request: There was a problem with the parameters of the request. Body of an error/warning message. Title is: Invalid Request"}
}
那么有没有人成功用这个,或者你知道一种使用facebook iOS SDK向facebook用户发送请求的方法吗?
谢谢
您可以使用Facebook SDK轻松发送应用程序请求
如需制作应用程序请求请确保执行以下步骤
1)确保在应用程序文件夹中添加了最新的Facebook SDK
如果没有,你可以从下载该链接。
现在,您只需在项目文件夹中添加FBConnect文件夹即可。
2)然后确保您已将您的iphone应用程序注册为“Facebook上的应用程序”类型在“基本应用程序设置”下选择您的应用程序如何与Facebook集成。
如果没有,你可以在这里做。
NSString *friendId=@"FacebookId Of Your Friends";
NSLog(@"%@",friendId);
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Hi please add me as a friend.", @"message",
friendId, @"to",
nil];
[appDelegate.facebook dialog:@"apprequests" andParams:params andDelegate:self];
请不要忘记在ViewController类中首先采用FBdialogDelegate协议。
仅使用POST方法,无法在没有对话框的情况下发送应用程序请求。
根据文件 :
此SDK提供了弹出Facebook对话框的方法。 当前支持的对话框是授权流程中使用的登录和权限对话框,以及用于将帖子发布到用户的源的对话框。
因此,您也无法通过标准对话框发布应用请求。 它仅适用于Web应用程序。
andyc,使用这种方式你只能发送App请求。 请确保您已将App注册为“App On Facbook”。 问题是,为了在桌面网站上显示通知,您的Facebook App需要定义Canvas URL。 URL甚至不需要有效,只需要在应用程序的设置中定义。 我已经通过测试应用验证了这确实解决了问题。 这是由Facebook有意完成的,因为当用户点击通知时,它们会被发送到桌面网站上的Canvas URL
我以同样的方式做了事情,我在通知中收到了App请求。 仍然有发送应用程序请求的问题,请查看以下链接
试试这段代码,
NSDictionary *params = @{@"to":text};
NSString *message = @"MESSAGE";
NSString *title = @"TITLE";
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:message
title:title
parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Request not sent" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
// Case B: User clicked the "x" icon
UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Canceled request" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
NSLog(@"User canceled request.");
}
else
{
UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Request sent successfully" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
NSLog(@"Request Sent. %@", params);
}
}
}];
我能够通过标准POST向/ me / apprequests使用Ruby发送请求。 我为应用程序提供了有效的access_token和“message”参数。 有可能,iOS SDK还没有对话框。
注意:用户必须先安装应用程序,然后才能向他们发送通知和邀请。 所以安德鲁是对的。 目前还无法发送应用请求邀请某人加入新应用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.