使用og_likes iOS功能错误喜欢facebook状态

时间:2014-01-13 23:19:41

标签: ios facebook facebook-graph-api

我正在尝试在我的应用程序中实现“喜欢状态”。我正在使用Facebook SDK参考,并提出了这段代码:

- (void) likeAStatus : (NSString *) postId {
NSString *post = [NSString stringWithFormat:@"http://facebook.com/%@", postId];

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                        post, @"object",
                        nil
                        ];
/* make the API call */
[FBRequestConnection startWithGraphPath:@"/me/og.likes"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          NSLog(@"Result is %@", result);
                          NSLog(@"Error is %@", error);

                          NSString *idFromCreate = [NSString stringWithFormat:@"/%@", [result objectForKey:@"id"]];

                          /* make the API call */
                          [FBRequestConnection startWithGraphPath:idFromCreate
                                                       parameters:params
                                                       HTTPMethod:@"POST"
                                                completionHandler:^(
                                                                    FBRequestConnection *connection,
                                                                    id result,
                                                                    NSError *error
                                                                    ) {
                                                    NSLog(@"Result is %@", result);
                                                    NSLog(@"Error is %@", error);
                                                }];
                      }];
}

现在当我在一个我以前不喜欢的帖子上运行它时(我现在只是编写了postID)我在控制台中得到了这个响应:(我只是打印动作ID以确保它是正确解析响应)

2014-01-13 15:59:43.766 Unifeed[5336:70b] Result is {
    id = 10151765515511916;
}
2014-01-13 15:59:43.767 Unifeed[5336:70b] Error is (null)
2014-01-13 15:59:43.767 Unifeed[5336:70b] The ID is /10151765515511916
2014-01-13 15:59:44.052 Unifeed[5336:70b] Result is {
    "FACEBOOK_NON_JSON_RESULT" = true;
}
2014-01-13 15:59:44.053 Unifeed[5336:70b] Error is (null)

这看起来很有效,不幸的是,当我去查看我的Facebook并查看这个特定的帖子时,它不被喜欢....如果我检查我的活动登录Facebook我没有看到我喜欢这个状态。

有关正在发生的事情的任何想法或对喜欢状态更新的不同方法的任何建议?还有“FACEBOOK_NON_JSON_RESULT”=真的好吗?

非常感谢!

1 个答案:

答案 0 :(得分:1)

我已经弄明白了 - 这是图API调用的一个区别。现在代码看起来像这样:

- (void) likeAStatus : (NSString *) postId {
NSString *post = [NSString stringWithFormat:@"%@/likes", postId];

/* make the API call */
[FBRequestConnection startWithGraphPath: post
                             parameters:nil
                             HTTPMethod:@"POST"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          NSLog(@"Result is %@", result);
                          NSLog(@"Error is %@", error);
                      }];
}

希望将来可以帮助某人!!

安迪