Google Plus Counter


/ Published in: PHP
Save to your folder(s)

interesting app: http://codecanyon.net/item/socialcounter-php-class-social-statistics/282826


Copy this code and paste it in your HTML
  1. function get_google_plus1_count($url)
  2. {
  3. $ch = curl_init();
  4. CURLOPT_HTTPHEADER => array('Content-type: application/json'),
  5. CURLOPT_POST => true,
  6. 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"}]',
  7. CURLOPT_RETURNTRANSFER => true,
  8. CURLOPT_SSL_VERIFYPEER => false,
  9. CURLOPT_URL => 'https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ'
  10. ));
  11. $res = curl_exec($ch);
  12. curl_close($ch);
  13.  
  14. if( $res )
  15. {
  16. $json = json_decode($res,true);
  17. return $json[0]['result']['metadata']['globalCounts']['count'];
  18. }
  19. return false;
  20. }

URL: http://lucido-media.de/blog/php-google-plus-one-count-api

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.