API为OG Post返回成功,但它不会出现在Facebook个人资料中

时间:2014-01-14 18:16:42

标签: ios facebook-graph-api facebook-opengraph

我正在开发一个简单的应用程序,它具有组合用户图片的功能,并将其作为OG故事发布到Facebook。

我关注了Facebook文档并且我发出了POST请求(我知道我可以批量处理它们,我只是想让任何版本工作),我确实得到了一个故事ID,但我找不到在Facebook上的故事。 (权限设置为朋友)

我用路径/ me /发布它: 当我在Graph Explorer中检查时,此路径返回一个空{'data':[]} 我知道故事不会发布在我的个人资料中,但我需要在某个地方看到它。

我需要测试诸如深层链接之类的东西(我知道url目前设置为nil),但我找不到故事!我能够设法看到这张照片的唯一地方就是我去的地方 开发者页面并单击“预览”。

有什么想法吗? 提前谢谢。

以下是源代码:

- (void) publishPhoto
{
    // stage an image
    [FBRequestConnection startForUploadStagingResourceWithImage:self.photo.image completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if(!error) {
            NSLog(@"Successfuly staged image with staged URI: %@", [result objectForKey:@"uri"]);

            // instantiate a Facebook Open Graph object
            NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPostWithType:@"<APPNAMESPACE>:picture" title:@"" image:@[@{@"url":[result objectForKey:@"uri"], @"user_generated" : @"true"}] url:nil description:@""];

            // Post custom object
            [FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                if(!error) {
                    // get the object ID for the Open Graph object that is now stored in the Object API
                    NSString *objectId = [result objectForKey:@"id"];
                    NSLog([NSString stringWithFormat:@"object id: %@", objectId]);

                    // create an Open Graph action
                    id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
                    [action setObject:objectId forKey:@"picture"];

                    // create action referencing user owned object
                    [FBRequestConnection startForPostWithGraphPath:@"/me/<APPNAMESPACE>:take" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                        if(!error) {
                            NSLog([NSString stringWithFormat:@"OG story posted, story id: %@", [result objectForKey:@"id"]]);
                            [[[UIAlertView alloc] initWithTitle:@"OG story posted"
                                                        message:@"Check your Facebook profile or activity log to see the story."
                                                       delegate:self
                                              cancelButtonTitle:@"OK!"
                                              otherButtonTitles:nil] show];
                        } else {
                            // An error occurred, we need to handle the error
                            // See: https://developers.facebook.com/docs/ios/errors
                            NSLog(@"Encountered an error posting to Open Graph: %@", error.description);
                        }
                    }];

                } else {
                    // An error occurred, we need to handle the error
                    // See: https://developers.facebook.com/docs/ios/errors
                    NSLog(@"Encountered an error posting to Open Graph: %@", error.description);
                }
            }];

        } else {
            // An error occurred, we need to handle the error
            // See: https://developers.facebook.com/docs/ios/errors
            NSLog(@"Error staging an image: %@", error.description);
        }
    }];
}

1 个答案:

答案 0 :(得分:0)

尝试用iPhone设备代替模拟器。它会工作