Facebook iOS SDK - 向Facebook用户发送应用请求

Facebook iOS SDK  - 向Facebook用户发送应用请求

问题描述:

我尝试使用facebook iOS SDK通过Facebook发送应用请求,我使用以下代码:

Im trying to send an app request through facebook using the facebook iOS SDK, im using the following code:

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用户发送请求吗?

So has anyone been successful with this, or do you know of a way to send a request to a facebook user using the facebook iOS SDK?

谢谢

您可以使用Facebook SDK轻松发送应用程序请求

You can easily send the app request very easily by Using Facebook SDK

制作应用程序请求请确保执行以下步骤

For Making App Request Please Make sure Following steps

1)确保在应用程序文件夹中添加了最新的Facebook SDK

如果没有,您可以从链接。

if not,you may download from this link.

现在您只需要在项目文件夹中添加FBConnect文件夹。

Now you just need to Add FBConnect Folder in your Project Folder.

2)然后确保已将您的iphone应用程序注册为Facebook上的应用程序类型选择您的应用程序在基本应用程序设置下与Facebook集成的

如果没有,你可以这样做这里

if not,you can do that here.

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协议。