RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.74% (6.40%*) • Investment PI: 5.49% (6.27%*)

Google Plus One Count With PHP

Google have recently depreciated the Google +1 count feature that was once a flagship feature of the platform. If you're interested in retrieving the count for any of your pages, the following function continues to work... although access can't be relied upon.

At the time of writing it's a little unclear how the +1 features will continue to work from within the platform.

1
<?php 
2
/*
3
 Google Plus One Count With PHP
4
 http://www.beliefmedia.com/code/php-snippets/google-plus-one
5
*/
6
 
7
function beliefmedia_get_plusones($url) {
8
 
9
  $curl = curl_init();
10
  curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
11
  curl_setopt($curl, CURLOPT_POST, 1);
12
  curl_setopt($curl, 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"}]');
13
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
14
  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
15
  $curl_results = curl_exec ($curl);
16
  curl_close ($curl);
17
 
18
  $json = json_decode($curl_results, true);
19
 
20
 return intval( $json[0]['result']['metadata']['globalCounts']['count'] );
21
}
22
 
23
/* Usage */
24
$url = 'http://www.internoetics.com/2012/05/16/count-shares-to-facebook-twitter-linkedin-googleplus/';
25
echo beliefmedia_get_plusones($url);

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment