2

我正在使用 Parse 移动平台在 facebook 时间轴上发布提要。这就是他们在文档中所说的:Note that if you already have the Facebook SDK installed in your app, our version of the Facebook SDK will happily work alongside it.

看看这里The Parse SDK includes the entire Facebook SDK. All the classes are namespaced with PF_ to avoid conflicts with existing libraries. So, for example, the main Facebook object class in our SDK is 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

问题是我可以发布photo or Status使用 Parse,但不能发布您看到的链接。

我很感激任何帮助。

4

2 回答 2

2

问题是Parse我使用的框架版本。你也可以在这里查看

例如,该版本(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];
        }];
    }];
于 2012-10-28T20:06:09.067 回答
0

您必须检查您的应用程序拥有的权限。来自Facebook SDK 文档

不足范围:请求需要比访问令牌提供的权限更高的权限。资源服务器应该以 HTTP 403(禁止)状态代码响应,并且可以包含“范围”属性以及访问受保护资源所需的范围。

于 2012-10-26T10:30:04.587 回答