1
我添加了自定義的Google+和Facebook按鈕,並通過MY ajax更新了計數器...如何測試Google+和Facebook按鈕?
這裏是代碼(我也包含在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
我改變的URL「http://www.google.com」,它顯示了所有網站計數器3點...
我在我的Facebook牆上分享鏈接,用我的彈出窗口(代碼如下)但計數器沒有更新(它沒有更新兩天)... 對於Google+我不喜歡沒有帳戶,所以我無法測試它...
有人可以告訴我如何測試這些? 因爲從我看到它不工作...
分享我彈出這個網址對於Facebook:
"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+櫃檯是否正常工作?
謝謝!現在