# share-button/1.5/classes/network/googleplus.php

Social Share Buttons, version 1.5. 70 lines.

- Page: https://pluginprobe.com/plugins/share-button/1.5/code/classes/network/googleplus.php
- Raw: https://pluginprobe.com/plugins/share-button/1.5/raw/classes/network/googleplus.php
- Modified: 2018-06-27T12:26:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/share-button/1.5/code/classes/network/googleplus.php#L10-L20`.

```php
<?php
namespace MBSocial;

class googleplusNetwork extends mbNetwork
{
	protected $network = 'googleplus';
	protected $icon = 'fa-google-plus-g';
	protected $color = '#dd4b39';

	public function __construct()
	{
		parent::__construct();

		$this->label = __('+1','mbsocial');
		$this->share_url = 'https://plus.google.com/share?url={url}';
		$this->profile_url = 'https://plus.google.com/{profile}';
		$this->countable = true;
		$this->count_api = '{url}';
		$this->popup_dimensions = array(600,600);
	}

	public function remoteRequest($url)
	{
		 $args = array(
            'method' => 'POST',
            'headers' => array(
                // setup content type to JSON
                'Content-Type' => 'application/json',
            ),
            // setup POST options to Google API
            'body' => json_encode(array(
                'method' => 'pos.plusones.get',
                'id' => 'p',
                'method' => 'pos.plusones.get',
                'jsonrpc' => '2.0',
                'key' => 'p',
                'apiVersion' => 'v1',
                'params' => array(
                    'nolog' => true,
                    'id' => $url,
                    'source' => 'widget',
                    'userId' => '@viewer',
                    'groupId' => '@self',
                ),
             )),

            'sslverify' => false,
        );
	  $response = wp_remote_post('https://clients6.google.com/rpc', $args);


	 	if (is_wp_error($response) || $response['response']['code'] != 200) {
			return false;
		}
		else {
			$result = wp_remote_retrieve_body($response);
		}

		$result = json_decode($result, true);
		$count = 0;
		if (isset($result['result']['metadata']['globalCounts']['count']))
	 	{	$count = intval($result['result']['metadata']['globalCounts']['count']);
	 		return $count;
	 	}

 		return 0;

	}
}

```
