iphone - 使用 Parse 发布 Facebook Timeline 的链接

标签 iphone objective-c ios facebook

我正在使用 Parse 移动平台在 Facebook 时间轴上发布提要。他们在文档中是这么说的:请注意,如果您已经在应用中安装了 Facebook SDK,我们的 Facebook SDK 版本将很乐意与它一起使用。

看看hereParse SDK 包括整个 Facebook SDK。所有类都以 PF_ 命名,以避免与现有库发生冲突。例如,我们 SDK 中的主要 Facebook 对象类是 PF_Facebook。

这个可以完美地使用 Facebook SDK :

- (IBAction)postFacebook:(UIButton *)sender {    
    self.postParams =
    [[NSMutableDictionary alloc] initWithObjectsAndKeys:
     @"https://developers.facebook.com/ios", @"link",
     @"https://developers.facebook.com/attachment/iossdk_logo.png", @"picture",
     @"Facebook SDK for iOS", @"name",
     @"Here we go", @"message",
     @"Build great social apps and get more installs.", @"caption",
     @"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", @"description",
     nil];

    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST"
     completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        [self showAlert:@"Link is posted" result:result error:error];
     }];
}

但是当我使用 PF_FBRequestConnection 时,它不起作用:

[PF_FBRequestConnection startWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"
        completionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error) {
            [self showAlert:@"Link is posted" result:result error:error];
    }];

控制台中的错误:

Error: HTTP status code: 403

问题是我可以使用 Parse 发布照片或状态,但不能发布您所看到的链接。

感谢您的帮助。

最佳答案

问题是我使用的 Parse 框架的版本。您可以查看here还有。

例如,该版本 (1.1.12) 不支持此版本:

[PF_FBSession.activeSession handleDidBecomeActive];

在新版本(1.1.13)中问题已解决。所以我可以有这个方法:

// Convenience method to perform some action that requires the "publish_actions" permissions.
- (void) performPublishAction:(void (^)(void)) action {
    // we defer request for permission to post to the moment of post, then we check for the permission
    if ([PF_FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
        // if we don't already have the permission, then we request it now
        [PF_FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
            defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(PF_FBSession *session, NSError *error) {
                if (!error) {
                    action();
                }
            //For this example, ignore errors (such as if user cancels).
        }];
    } else {
        action();
    }
}

并以这种方式使用它:

[self performPublishAction:^{
        [PF_FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST"
            completionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error) {
                [self showAlert:@"Link is posted" result:result error:error];
        }];
    }];

关于iphone - 使用 Parse 发布 Facebook Timeline 的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13084259/

相关文章:

objective-c - 在 Objective-C 中使用文件偏移量

iphone - iOS Core 数据关系故障

ios - 单击“在Safari中打开”按钮后,深层链接断开

iphone - 为什么使用属性?

iphone - 表单与 UITableView

iphone - 在整个 iOS 应用程序中共享字符串和变量

iphone - 启用 ARC 的 TWTweetComposeViewController 内存泄漏

iphone - 从 Objective-C 中的方法返回多个值

ios - 在 ios 上注册为组织

ios - TableView 填充行,但不填充内容