我添加了自定义Google+和Facebook按钮,计数器已更新为MY ajax ...
这是代码(我也包含在twitter计数器中,所以它对其他人有用,但它的计数器确实有效):
$url = "URL OF PAGE";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$curl_results = curl_exec ($ch);
curl_close ($ch);
$parsed_results = json_decode($curl_results, true);
echo $parsed_results[0]['result']['metadata']['globalCounts']['count']; //Google+ counter for this URL
$fbresponse = file_get_contents('http://graph.facebook.com/' .$url);
$fbresponse_c = json_decode($fbresponse,true);
if ( $fbresponse_c['shares'] ) { echo $fbresponse_c['shares']; } else { echo '0'; } //Facebook counter for this URL
$twresponse = file_get_contents('http://cdn.api.twitter.com/1/urls/count.json?url=' .$url. '&callback=twttr.receiveCount');
$twresponse = str_replace('twttr.receiveCount(' ,'', $twresponse);
$twresponse = str_replace(')' ,'', $twresponse);
$twresponse_c = json_decode($twresponse,true);
echo $twresponse_c['count']; //Twitter counter for this URL
我将网址更改为“http://www.google.com”,并显示所有网站3个网站的计数器......
我在Facebook Wall上共享链接,使用我的弹出窗口(代码如下)但计数器没有更新(它没有更新两天)... 对于Google+,我没有帐号,所以我无法测试...
有人可以告诉我如何测试这些吗? 从我看来它不起作用......
为了共享,我弹出了Facebook的这个URL:
"http://www.facebook.com/sharer.php?u=" + escape(url) + "&t=Some text"
这是谷歌的一个:
"https://plusone.google.com/u/0/+1/profile/?type=po&source=p&parent=https%3A%2F%2Fplusone.google.com&hl=en_US&ru=" + escape(urll)
facebook多久更新一次的计数器? 我该怎么检查这个Google+计数器是否正常工作?
谢谢!
答案 0 :(得分:0)
现在一切都在更新...... Facebook即时,我开了Google+帐户,所以我也测试了它,它也在工作......
- 封闭 -