Use Google+ counter by Yandex.
There is one limitation: it will show counter only for the first button set (=== share URL) on a page.master
parent
33bae0ac72
commit
b6bf82ee54
11
Readme.md
11
Readme.md
|
@ -161,14 +161,6 @@ $('.social-likes').on('counter.social-likes', function(event, service, number) {
|
|||
});
|
||||
```
|
||||
|
||||
### Experimental Google+ counter
|
||||
|
||||
Place `googleplusonecount.php` somewhere on your server. And change buttons HTML like this:
|
||||
|
||||
```html
|
||||
<li class="plusone" data-counter="http://example.com/path/to/googleplusonecount.php?url={url}&callback=?">Google+</li>
|
||||
```
|
||||
|
||||
### Adding your own button
|
||||
|
||||
You can find some custom buttons in `contrib` folder.
|
||||
|
@ -196,7 +188,6 @@ var socialLikesButtons = {
|
|||
};
|
||||
```
|
||||
|
||||
|
||||
Add some CSS:
|
||||
|
||||
```css
|
||||
|
@ -241,10 +232,12 @@ You can add additional Twitter data using [Twitter Card](https://dev.twitter.com
|
|||
|
||||
See [wiki](https://github.com/sapegin/social-likes/wiki/How-to-use-Social-Likes-with-Wordpress,-etc.).
|
||||
|
||||
|
||||
## Release History
|
||||
|
||||
The changelog can be found in the `Changelog.md` file.
|
||||
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Google +1 counter JSONP proxy for Social Likes
|
||||
* http://sapegin.github.com/social-likes
|
||||
*
|
||||
* Usage:
|
||||
* //example.com/googleplusonecount.php?url=http%3A//google.com/&callback=foo
|
||||
*
|
||||
* @author Artem Sapegin
|
||||
* @copyright 2011 Artem Sapegin (sapegin.ru)
|
||||
* @license http://creativecommons.org/licenses/by/3.0/
|
||||
*/
|
||||
|
||||
// http://openminds.lucido-media.de/php-google-plus-one-count-api
|
||||
function get_google_plusone_count($url) {
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, 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'
|
||||
));
|
||||
$result = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
return $json[0]['result']['metadata']['globalCounts']['count'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($_GET['callback']) || empty($_GET['url'])) {
|
||||
header('HTTP/1.0 400 Bad request');
|
||||
exit();
|
||||
}
|
||||
|
||||
print $_GET['callback'] . '("' . get_google_plusone_count($_GET['url']) . '")';
|
||||
|
||||
?>
|
|
@ -87,7 +87,7 @@ td {
|
|||
<div class="mailru" title="Опубликовать ссылку в Моём мире">Мой мир</div>
|
||||
<div class="vkontakte" title="Опубликовать ссылку во Вконтакте">Вконтакте</div>
|
||||
<div class="odnoklassniki" title="Опубликовать ссылку в Одноклассниках">Одноклассники</div>
|
||||
<div class="plusone" data-counter="http://sapegin.ru/api/social-likes/googleplusonecount.php?url={url}&callback=?" title="Опубликовать ссылку в Гугл-плюсе">Google+</div>
|
||||
<div class="plusone" title="Опубликовать ссылку в Гугл-плюсе">Google+</div>
|
||||
<div class="pinterest" data-media="http://s3-ec.buzzfed.com/static/enhanced/webdr02/2013/8/20/11/anigif_enhanced-buzz-31256-1377012172-9.gif" title="Опубликовать ссылку в Пинтересте">Pinterest</div>
|
||||
</div>
|
||||
|
||||
|
@ -99,7 +99,7 @@ td {
|
|||
<li class="mailru" title="Опубликовать ссылку в Моём мире">Мой мир</li>
|
||||
<li class="vkontakte" title="Опубликовать ссылку во Вконтакте">Вконтакте</li>
|
||||
<li class="odnoklassniki" title="Опубликовать ссылку в Одноклассниках">Одноклассники</li>
|
||||
<li class="plusone" data-counter="http://sapegin.ru/api/social-likes/googleplusonecount.php?url={url}&callback=?" title="Опубликовать ссылку в Гугл-плюсе">Google+</li>
|
||||
<li class="plusone" title="Опубликовать ссылку в Гугл-плюсе">Google+</li>
|
||||
<li class="pinterest" data-media="http://s3-ec.buzzfed.com/static/enhanced/webdr02/2013/8/20/11/anigif_enhanced-buzz-31256-1377012172-9.gif" title="Опубликовать ссылку в Пинтересте">Pinterest</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -104,6 +104,24 @@ var services = {
|
|||
popupHeight: 360
|
||||
},
|
||||
plusone: {
|
||||
counterUrl: 'http://share.yandex.ru/gpp.xml?url={url}',
|
||||
counter: function(jsonUrl, deferred) {
|
||||
var options = services.plusone;
|
||||
if (options._) return;
|
||||
|
||||
if (!window.services) window.services = {};
|
||||
window.services.gplus = {
|
||||
cb: function(number) {
|
||||
options._.resolve(number);
|
||||
}
|
||||
};
|
||||
|
||||
options._ = deferred;
|
||||
$.ajax({
|
||||
url: makeUrl(jsonUrl),
|
||||
dataType: 'jsonp'
|
||||
});
|
||||
},
|
||||
popupUrl: 'https://plus.google.com/share?url={url}',
|
||||
popupWidth: 700,
|
||||
popupHeight: 500
|
||||
|
|
Loading…
Reference in New Issue