1

カスタムのGoogle+ボタンとFacebookボタンを追加し、カウンターがMYajaxで更新されました...

コードは次のとおりです(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つのサイト...

ポップアップを使用してFacebookWallでリンクを共有しましたが(コードは下にあります)、カウンターは更新されませんでした(2日間更新されませんでした)...そして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+カウンターが正常に機能しているかを確認できますか?

ありがとう!

4

1 に答える 1

0

すべてが今更新されています...Facebookはすぐに、そして私はGoogle+アカウントを開設したので、それもテストしました、それも機能しています...

-閉まっている-

于 2011-09-22T09:08:10.320 に答える