PluginProbe
Social Share Buttons / 1.2
Social Share Buttons v1.2
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
share-button / classes / network / googleplus.php

googleplus.php in Social Share Buttons 1.2, at classes/network/googleplus.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MBSocial;
3
4 class googleplusNetwork extends mbNetwork
5 {
6 protected $network = 'googleplus';
7 protected $icon = 'fa-google-plus-g';
8 protected $color = '#dd4b39';
9
10 public function __construct()
11 {
12 parent::__construct();
13
14 $this->label = __('+1','mbsocial');
15 $this->share_url = 'https://plus.google.com/share?url={url}';
16 $this->profile_url = 'https://plus.google.com/{profile}';
17 $this->countable = true;
18 $this->count_api = '{url}';
19 $this->popup_dimensions = array(600,600);
20 }
21
22 public function remoteRequest($url)
23 {
24 $args = array(
25 'method' => 'POST',
26 'headers' => array(
27 // setup content type to JSON
28 'Content-Type' => 'application/json',
29 ),
30 // setup POST options to Google API
31 'body' => json_encode(array(
32 'method' => 'pos.plusones.get',
33 'id' => 'p',
34 'method' => 'pos.plusones.get',
35 'jsonrpc' => '2.0',
36 'key' => 'p',
37 'apiVersion' => 'v1',
38 'params' => array(
39 'nolog' => true,
40 'id' => $url,
41 'source' => 'widget',
42 'userId' => '@viewer',
43 'groupId' => '@self',
44 ),
45 )),
46
47 'sslverify' => false,
48 );
49 $response = wp_remote_post('https://clients6.google.com/rpc', $args);
50
51
52 if (is_wp_error($response) || $response['response']['code'] != 200) {
53 return false;
54 }
55 else {
56 $result = wp_remote_retrieve_body($response);
57 }
58
59 $result = json_decode($result, true);
60 $count = 0;
61 if (isset($result['result']['metadata']['globalCounts']['count']))
62 { $count = intval($result['result']['metadata']['globalCounts']['count']);
63 return $count;
64 }
65
66 return 0;
67
68 }
69 }
70