朋友您好我想用我的Android应用发布评论到facebook的特定帖子,下面是我的代码 -
我从网址
获取所有评论http://retirementhomeslisting.com/home-detail/canterbury-place-83
Bundle mBundle=new Bundle();
mBundle.putString("message","testing...1234555");
@SuppressWarnings("deprecation")
Facebook fb=new Facebook(getResources().getString(R.string.fb_app_id));
try {
fb.request("478409145610921/comments",mBundle,"POST");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在这里,我提供了一个链接,您可以看到所有评论列表,其中包含上述object_id
Link for comment list for 478409145610921 object_id
当我在上面运行时,代码注释不会发布各自的object_id所以任何想法我怎么能解决它? 编辑回答
Bundle mBundle=new Bundle();
mBundle.putString("message","testing...1234555");
@SuppressWarnings("deprecation")
Facebook fb=new Facebook(getResources().getString(R.string.fb_app_id));
try {
fb.request("1309634065_478409145610921/comments",mBundle,"POST");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
答案 0 :(得分:3)
要在帖子上发表评论,您需要post_id
代替object_id
。
因此,您的API调用必须是 -
/{post_id}/comments
(post_id
也是comments表中的字段)
修改强>
您必须使用评论插件并尝试发布评论。不幸的是,facebook不允许你这样做! (逻辑 - 因为大多数都是公开的,以避免发送垃圾邮件,否则任何人都可能会对该帖子发表评论)
如果您在此处查看回复,则会获得:
{
"error": {
"message": "(#100) Comments may not be added to a comment plugin",
"type": "OAuthException",
"code": 100
}
}
您也可以在Graph API Explorer上测试这些API调用。
答案 1 :(得分:0)
使用Graph API:
...
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) {
[[[FBSDKGraphRequest alloc]
initWithGraphPath:@"post_id/likes"
parameters: @{ @"like" : @"true"}
HTTPMethod:@"POST"]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"It was liked.");
}
}];
}
...