Posted By

czachor on 02/16/12


Tagged

google plus


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

AllKnightAccess
bug5


Google Plus Counter


 / Published in: PHP
 

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

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

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

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: upgradedtutorials on January 19, 2013

hello there, there's a new way to get the google plus's counts, check this link http://www.upgradedtutorials.info/php/getting-google-plus-count-using-php-curl/. the code was so handy and useful, you can also use it as much as you want. Sparky!

You need to login to post a comment.