开发者

Facebook Social Plugin comment count

I'm using facebook connect and facebook social plugin comment ( ). I want to get comment count from current page. How to write it ? Need to use FQL ? If fql,

SELECT count(*) FROM comments WHERE xid= ?

what xid should I add? How to get xid from current address ?开发者_JS百科


<?php
session_start();

$fbconfig['appid' ]  = "1111111";
$fbconfig['api'   ]  = "2222222";
$fbconfig['secret']  = "3333333";

$xid = 'myCommentBox'; 

include_once "facebook.php";

$facebook = new Facebook(array(
    'appId'  => $fbconfig['appid' ],
    'secret' => $fbconfig['secret'],
    'cookie' => true,
));

$fql = "SELECT count FROM comments_info WHERE app_id = '".$fbconfig['appid' ]."' AND xid = '$xid' ";
$param  =   array(
    'method'    => 'fql.query',
    'query'     => $fql,
    'callback'  => ''
);
$fqlResult   =   $facebook->api($param);
print_r( $fqlResult );
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Count FB comment!</title>
    </head>
<body>
<div id="fb-root"></div>
   <script src="http://connect.facebook.net/en_US/all.js#appId=<?=$fbconfig['appid' ]?>&amp;xfbml=1"></script>
   <fb:comments xid="<?=$xid?>" numposts="10" width="600" publish_feed="true"></fb:comments>
</body>
</html>


you just neeed to query comments_info by providing your app id, It will return xid and count specific to a particular xid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜