Facebook comment counter on social networks

I use facebook connect and facebook social plugin comment (). I want to get the number of comments from the current page. How to write this? Need to use FQL? If fql,

SELECT count(*) FROM comments WHERE xid= ?

which xid should be added? How to get xid from current address?

+3
source share
2 answers
<?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>
+5
source

you just want to request comment_info with your application id, it will return xid and a specific xid-specific count.

+1
source

Source: https://habr.com/ru/post/1750046/


All Articles