【问题标题】:Send friend request from IOS using facebook SDK使用 facebook SDK 从 IOS 发送好友请求
【发布时间】:2013-06-04 13:59:29
【问题描述】:

我正在尝试使用 facebook SDK 从 IOS 发送好友请求,

这是我的代码

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"My Title", @"title",
                                   @"Come check out my app.",  @"message",
                                   FrienduserId, @"id",
                                   nil];


    [FBWebDialogs  presentDialogModallyWithSession:appDelegate.session dialog:@"friends" parameters:[params mutableCopy] handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
        if (error) {
            NSLog(@"%@",error);
        }
        else
        {
            NSLog(@"done");
        }
    }];

询问确认信息(参考friendrequest.png),点击确认按钮后显示错误

“抱歉,出了点问题,我们正在努力尽快解决这个问题”(参考 error.png)

谁能帮帮我

Facebook SDK 版本 3.5.1 和 xCode 版本 4.6

【问题讨论】:

标签: ios facebook


【解决方案1】:

尝试将您的代码更改为:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"My Title", @"title",
                                   @"Come check out my app.",  @"message",
                                   FrienduserId, @"id",
                                   nil];    
[FBWebDialogs  presentDialogModallyWithSession:appDelegate.session dialog:@"friends" parameters:[params mutableCopy] handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)];
            if (error) {
                NSLog(@"%@",error);
            }
            else
            {
                NSLog(@"done");
            }

这至少应该可以解决您的部分问题。可能还有其他问题,我只是修正了你的语法。

【讨论】:

  • 嗨,它在“ if (error) { ”附近给出错误为“使用未声明的标识符'错误'”。
  • 那我不知道。截屏并发布链接
  • @SantaClaus: appdelegate.session 在这里的意思
  • @Seeker 不完全确定。它在问题中被使用。