我遵循了这个指南,在发表评论时触发一个函数。我目前可以进行ajax调用,以便在发表评论时与我的DB进行交互。
FB Comments Plugin - Detect comment on page
我想做的是在每次评论时在我自己的数据库中保存评论的副本。我不确定我想永远使用facebook评论,所以我希望所有的数据都保存在我的数据库中,以防我恢复到原来的评论系统。
我尝试使用jquery从文本框中获取值,并从span中获取用户名。
var comment = $('.mentionsTextarea').val();
var username = $('.commentasName').html();此代码未获取数据。我猜是因为它在一个iframe里面。我想知道当评论提交被触发时,是否有可能从实际对象中获取数据。那么当事件被触发时,我可以从comment对象中获取数据吗?就像这样。
FB.Event.subscribe('comment.create',
function(response) {
var comment = comment.text();
var username = comment.username.text();
}发布于 2015-01-04 21:44:43
我没有我想要的答案,但我确实有一个解决方案。这将获得针对特定url的最新评论。
$comments = file_get_contents('https://graph.facebook.com/comments/?ids='.$url);
$comments = json_decode($comments, true);
$comments = $comments[$url]['comments']['data'];
$latestComment = $comments[0];
$username = $latestComment['from']['name'];
$message = $latestComment['message'];
echo $username ." - ".$message;https://stackoverflow.com/questions/27765799
复制相似问题