如何使用HTML5获得Facebook评论?
我知道两种方法获得的评论在Facebook上的号码:如何使用HTML5获得Facebook评论?
<fb:comments-count href=http://example.com/></fb:comments-count> awesome comments
和...
<iframe src="http://www.facebook.com/plugins/comments.php?href=example.com&permalink=1" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:130px; height:16px;" allowTransparency="true"></iframe>
但没有对HTML5解决方案的语义,有没有什么方法吗?
图形API例如使用jquery:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$.ajax({
url: 'http://graph.facebook.com/http://www.google.com',
dataType: 'jsonp',
success: function(data) {
alert("comments: " + data.comments);
}
});
});
</script>
+1我喜欢API的图形;) –
这是必须在最上面。 – sonnb
您还可以得到有效的HTML5 FB评论数是这样的:
<div class="fb-comments-count" data-href="/post URL">0</div>
FB了正确的号码会自动替换为 “0”。如果你把东西有没有像“真棒的意见”,将与评论的数量来代替,即“13”等
为了获得数量和使用自己的文字,做这样的事情:
<a href="/post URL"><div class="fb-comments-count" data-href="/post URL">0</div> awesome comments</a>
请注意,您必须将您的课程封装在div中,否则注释计数器将无法使用。
天才,谢谢! – TMC
对于WordPress邮寄u可以使用像<fb:comments-count href=<?php the_permalink();?>></fb:comments-count> awesome comments
你可以抓住数据从Facebook是,好了,从Facebook抓取数据的唯一途径。你需要使用他们的API之一来做到这一点,无论是JavaScript,PHP,红宝石,蟒蛇等... – Connor
谢谢Connor,但fb:comments-count是一个插件。 http://developers.facebook.com/docs/reference/plugins/comments/ –