1

我正在尝试创建一个开放图形对象,并将用户生成的照片上传到暂存资源,以便使用它发布操作。我正在使用适用于 iOS 的最新 Facebook SDK(3.5)。代码如下:

[FBRequestConnection startForUploadStagingResourceWithImage:self.image completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (!error){
            NSString *uri = [result valueForKey:@"uri"];

            NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
            object.provisionedForPost = YES;
            object[@"type"] = @"<APP_NAME>:<OBJECT_NAME>";
            object[@"url"] = uri;
            object[@"title"] = @"My Title";
            object[@"user_generated"] = @"true";

            [FBRequestConnection startForPostOpenGraphObject:object
                                           completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

    }];
}];

在完成块中startForPostOpenGraphObject我应该startForPostWithGraphPath用新创建的对象的 id 调用。但是,我没有得到 id,而是一个错误:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1f2f14a0 {com.facebook.sdk:HTTPStatusCode=500, com.facebook.sdk:ParsedJSONResponseKey={
body =     {
    error =         {
        code = 1;
        message = "An unknown error has occurred.";
        type = OAuthException;
    };
};
code = 500;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x1f2ca300, state: FBSessionStateOpen, loginHandler: 0x1f2cb750, appID: **************, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x1e56ed00>, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2013-05-08 09:07:56 +0000, `attemptedRefreshDate`: 0001-12-30 00:00:00 +0000, permissions:(
"user_photos",
"publish_stream",
"publish_actions"
)>}

我究竟做错了什么?

4

1 回答 1

0

url 和 user_generated 属性都需要放在 image 属性下,它也是一个数组,所以这样的东西应该可以工作:

object[@"type"] = @"<APP_NAME>:<OBJECT_NAME>";
object[@"title"] = @"My Title";
object[@"image"] = @[@{@"url": uri, @"user_generated":@"true"}];

您还可以查看 Scrumptious 示例,了解如何将其作为批处理请求的一部分。

于 2013-05-08T16:59:31.560 回答