首先,需要在facebook创建一个APP,创建方法见https://developers.facebook.com/,APP有一项是填写Domain的,这里填写你website的Domain。(APP是绑定domain的,不能乱填)
然后就可以使用facebook comments plugins。
使用facebook comments plugins,可以在页面中插入facebook comments。
生成code方法:https://developers.facebook.com/docs/plugins/comments
例如:有一个页面是http://www.example.com/ ,在这个页面中插入以下代码便可以使用comments plugings。
<!-- include facebook js sdk --> <script id="facebook-jssdk" src="//connect.facebook.net/en_GB/all.js#xfbml=1&appId=这里填写APPID"></script> <!-- comments plugins --> <fb:comments colorscheme="light" numposts="4" height="360px;" width="614px" href="http://www.example.com/" fb-xfbml-state="rendered" class="fb_iframe_widget"></fb:comments>
在页面上显示如下
读取页面的分享总数与评论总数
https://graph.facebook.com/?ids={YOUR_URL}
{YOUR_URL} 需要 urlencode
例如:https://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2F
返回:
{ "http://www.example.com/": { "id": "http://www.example.com/", "shares": 399517, "comments": 392 } }
代码如下:
<?php $url = 'http://www.example.com/'; $api = 'https://graph.facebook.com/?ids='; $result = json_decode(file_get_contents($api.urlencode($url)), true); print_r($result); ?>
读取页面评论列表
https://graph.facebook.com/comments/?ids={YOUR_URL}
{YOUR_URL} 需要 urlencode
例如:https://graph.facebook.com/comments/?ids=http%3A%2F%2Fwww.example.com%2F
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索facebook
, 页面
, plugins
, https
, com
Example
facebook简介、facebook tip项目简介、facebook个人简介、facebook创始人简介、facebook公司简介,以便于您获取更多的相关知识。