To get prefers and impart information for a Url here’s a capacity to get Google Plus’ for any Url.
The Code
It’s worth pointing out you must have CURL enabled on your web server, I believe it’s enabled by default on PHP5 setups. Also the Key below Isn’t a unique API key you must leave the key as is to ensure the code works properly.
function gplus_shares($url){
// G+ DATA
$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_SSL_VERIFYPEER, false);
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’));
$result = curl_exec ($ch);
curl_close ($ch);
return json_decode($result, true);
}
Example Usage
$gplus = gplus_shares(‘https://facebook.com’);
echo $gplus[0][‘result’][‘metadata’][‘globalCounts’][‘count’];
My brother recommended I might like this web site.
He was totally right. This post truly made my
day. You can not imagine simply how much time I had spent for this info!
Thanks!