您好,欢迎访问一九零五行业门户网

在PHP站点的页面上添加Facebook评论插件的实例教程_php实例

首先,需要在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。

在页面上显示如下
读取页面的分享总数与评论总数
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 } }
代码如下:

读取页面评论列表
https://graph.facebook.com/comments/?ids={your_url}
{your_url} 需要 urlencode
例如:https://graph.facebook.com/comments/?ids=http%3a%2f%2fwww.example.com%2f
返回:
{ http://www.example.com/: { comments: { data: [ { id: 395320319544_27462154, from: { id: 100000223906701, name: thu\u1eadn phan thanh }, message: hello moto, can_remove: false, created_time: 2013-10-07t10:01:40+0000, like_count: 1, user_likes: false }, { id: 395320319544_27877980, from: { id: 100001638736612, name: l\u00e3 minh }, message: hi you, can_remove: false, created_time: 2013-11-13t02:57:01+0000, like_count: 4, user_likes: false }, { id: 395320319544_27879381, from: { id: 100004229015145, name: th\u00f9y dung }, message: mg \u1ee7ng h\u1ed9 t\u1edb v\u1edbi nh\u1edb \u003c3, can_remove: false, created_time: 2013-11-13t05:38:12+0000, like_count: 3, user_likes: false } ... ], paging: { cursors: { after: mju0, before: mzk4 }, next: https://graph.facebook.com/v1.0/395320319544/comments?limit=25&after=mju0 } } } }
根据next的url再请求可以获取下一页的评论内容
代码如下:

其它类似信息

推荐信息