gpt4 book ai didi

iOS Facebook Api,对评论帖子点赞

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:35:25 24 4
gpt4 key购买 nike

我想在 Facebook 上点赞帖子的评论,我使用与点赞帖子相同的方法。对于一个帖子,它有效,但对于一个评论失败。

文档: https://developers.facebook.com/docs/graph-api/reference/object/likes

我的代码:

[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"/%@/likes", postId_]
parameters:nil
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{ //Error:
}];

错误是:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x158999b0 {com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ParsedJSONResponseKey={ body = { error = { code = 100; message = "(#100) Error finding the requested story"; type = OAuthException; }; }; code = 400; }, com.facebook.sdk:ErrorSessionKey=}

最佳答案

我是这样做的,效果很好

    // post is my module object, encapsulates the info form the post
// pass the post ID
NSString *graphPath = [NSString stringWithFormat:@"%@/likes", post.postID];

FBRequest *request = [FBRequest requestForGraphPath:graphPath];
// DELETE or POST the like
NSString *method = post.liked?@"DELETE":@"POST";
[request setHTTPMethod:method];

[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
BOOL success = YES;
success = (error)?NO:YES;
if(success) {

}
}];

注意:确保你有发布权限

关于iOS Facebook Api,对评论帖子点赞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22665281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com