通过Javascript API发表评论

时间:2012-08-01 01:07:03

标签: javascript facebook-graph-api facebook-comments

我正在尝试使用javascript API发表评论。我首先获得特定url的评论列表:

FB.api('/fql', {q: {
  query0: 'SELECT comments_fbid FROM link_stat WHERE url="'+url+'"',
  query1: 'SELECT post_fbid, fromid, text, time, comments FROM comment WHERE object_id IN (SELECT comments_fbid FROM #query0) ORDER BY time DESC',
  query2: 'SELECT id, name FROM profile WHERE id IN (SELECT fromid FROM #query1)'
}}, function(resp) {
  ...
});

然后我可以发布到页面的comments_fbidpost_fbid来回复评论列表中的现有帖子。这些由下面的id表示:

FB.login(function(resp) {
  if (!resp.authResponse) return;
  FB.api('/'+id+'/comments', 'post', {message: 'Hello World', function(resp) {
    console.log(resp);
  });
}, {scope: 'publish_stream'});

如果我发布回复现有消息(即post_fbid),它可以正常工作,但如果我发布到顶级评论列表(即comments_fbid),我会得到错误:

{error: {code: 1, message: "An unknown error has occurred.", type: "OAuthException"}}

0 个答案:

没有答案