forked from pinceladasdaweb/Socialight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplus.php
39 lines (35 loc) · 1.11 KB
/
plus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
function plus_count($url) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_POST => true,
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"
}]',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_URL => 'https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ'
));
$res = curl_exec($ch);
curl_close($ch);
if ($res) {
$json = json_decode($res, true);
$arr = array('counter' => $json[0]['result']['metadata']['globalCounts']['count']);
return json_encode($arr);
}
};
$url = $_GET['url'];
echo plus_count($url);