Objective c 如何在ios中使用graph api评论facebook3.1中的帖子
我使用Facebook3.1,试着对某个帖子发表评论。我使用了以下代码。我在创建会话时也使用了以下权限:Objective c 如何在ios中使用graph api评论facebook3.1中的帖子,objective-c,ios,facebook,facebook-graph-api,Objective C,Ios,Facebook,Facebook Graph Api,我使用Facebook3.1,试着对某个帖子发表评论。我使用了以下代码。我在创建会话时也使用了以下权限: read_stream,offline_access,publish_stream,share_item 守则: NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", nil]; NSString *string=[
read_stream,offline_access,publish_stream,share_item
守则:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", nil];
NSString *string=[NSString stringWithFormat:@"https://graph.facebook.com/153125724720582_184234384932460/comments?access_token=%@",appDelegate.session.accessToken];
[FBRequestConnection startWithGraphPath:string
parameters:params
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Result: %@", result);
}
}];
Response :
Result: {
comments = 1;
id = "https://graph.facebook.com/153125724720582_184234384932460/comments";
}
但是我的消息没有在评论帖子id上更新
与Post请求相同的代码我也尝试过,但响应为:
Result: {
"FACEBOOK_NON_JSON_RESULT" = false;
}
您应该使用HTTP POST并确保用户已授予
publish\u stream
权限
您应该将API调用(和访问令牌)复制并粘贴到Graph Explorer中,以测试您的调用
(也可以使用access_token调试器确保有权限)您应该使用此
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Test Comment", @"message", nil];
[FBRequestConnection startWithGraphPath:@"153125724720582_184234384932460/comments"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error)
NSLog(@"Error: %@", [error localizedDescription]);
else
NSLog(@"Result: %@", result);
}];
嗨,James Pearce,感谢您使用Graph explorer回复,我可以对帖子发表评论,但在我的代码中,结果是“FACEBOOK\u NON\u JSON\u result”=false;你能帮我接电话吗this@SrikanthGto请发布调试器输出的访问令牌,代码正在使用密钥进行合作。最后,我很高兴听到这个消息。最终是这样吗?使用这个URL获得了成功responce@MitsB是的,我知道,因为Facebook改变了所有SDK,这是从2013年开始的:)