Answer the question
In order to leave comments, you need to log in
How to get google plus shares count?
Note:
Actually, the problem is in the title. The method used before now (for some reason) does not work:
$endpoint = 'https://plusone.google.com/u/0/_/+1/fastbutton?count=true&url=' . $url;
$session = curl_init($endpoint);
curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($session);
curl_close($session);
$tmp = [];
preg_match('#<div id="aggregateCount" class="Oy">(.+?)</div>#is', $result, $tmp);
return $tmp[1];
Answer the question
In order to leave comments, you need to log in
Found. Maybe someone will need:
$url = 'url';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ');
curl_setopt($curl, CURLOPT_POST, 1);
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"}]');
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$curl_result = curl_exec($curl);
curl_close($curl);
$json = json_decode($curl_result, true);
$shares = $json[0]['result']['metadata']['globalCounts']['count'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question