【问题标题】:Facebook Open Graph startForPostWithGraphPath returning "FACEBOOK_NON_JSON_RESULT" = trueFacebook Open Graph startForPostWithGraphPath 返回“FACEBOOK_NON_JSON_RESULT”= true
【发布时间】:2014-07-14 15:35:05
【问题描述】:

我正在尝试配置 Open Graph 帖子。我已经按照 FB 开发人员网站上的代码示例进行操作,并且使用 test_user,据说可以成功生成帖子。这是我的代码:

- (void)createOGObjectForImage:(NSURL *)imageURL
{
    NSMutableDictionary<FBGraphObject> *object =
    [FBGraphObject openGraphObjectForPostWithType:@"ogminigame:mini_game"
                                            title:@"Mini Game"
                                            image:@"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png"
                                              url:imageURL
                                      description:@""];

    [FBRequestConnection startForPostWithGraphPath:@"me" 
                                       graphObject:object
                                 completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                     if(!error) {
                                         NSLog(@"Result: %@", [result description]); 
                                         [self createOGActionWithResult:result];
                                     } else {
                                         NSLog(@"Error posting the Open Graph object to the Object API: %@", error);
                                         [self sharePhotoWithShareDialog:self openGraphAction:nil];
                                     }
                                 }];
}

但是,测试用户墙上没有出现任何内容。单步执行代码可以看到,当我创建OG对象时,结果有以下内容:

"FACEBOOK_NON_JSON_RESULT" = true;

更具体地说,它看起来像这样:

因此,当我创建我的操作时,当我尝试使用以下方法检索 objectID 时: NSString *objectId = [结果 objectForKey:@"id"];

它显然返回 nil。我错过了结果对象的阶段吗?我试过寻找类似的问题,但似乎没有太多的解释方式。

【问题讨论】:

    标签: objective-c facebook facebook-graph-api facebook-opengraph


    【解决方案1】:

    好吧,您提供自定义故事的 Facebook 开发人员网站上提供的代码似乎不正确。也就是说,它应该看起来像:

    - (void)createOGObjectForImage:(NSURL *)imageURL
    {
        NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPostWithType:@"ogminigame:mini_game"
                                                                                             title:@"Mini Game"
                                                                                             image:@"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png"
                                                                                               url:imageURL
                                                                                       description:@""];
    
        [FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
            if(!error) {
                NSLog(@"Result: %@", [result description]);
                [self createOGActionWithResult:result];
            } else {
                NSLog(@"Error posting the Open Graph object to the Object API: %@", error);
                [self sharePhotoWithShareDialog:self openGraphAction:nil];
            }
        }];
    }
    

    因此,您将字典转换为 FBOpenGraphObject,而不是 FBGraphObject,并调用 startForPostOpenGraphObject 而不是 startForPostWithGraphPath。

    在我看来,Facebook 需要与他们的文档更加一致。

    我仍然没有在 test_account 页面上显示任何内容,但至少上述似乎不是问题的原因......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 2012-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多