Skip to content

Instantly share code, notes, and snippets.

@ihorvorotnov
Last active May 26, 2024 08:13
Show Gist options
  • Save ihorvorotnov/9132596 to your computer and use it in GitHub Desktop.
Save ihorvorotnov/9132596 to your computer and use it in GitHub Desktop.
Get number of shares from social platforms
Facebook*:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
+ works, returns shares, likes, comments and total
Twitter:
http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
+ v1 API but still works
Reddit:
http://buttons.reddit.com/button_info.json?url=%%URL%%
+ works
LinkedIn:
http://www.linkedin.com/countserv/count/share?url=%%URL%%&format=json
+ works
Digg:
http://widgets.digg.com/buttons/count?url=%%URL%%
- NOT WORKING!
Delicious:
http://feeds.delicious.com/v2/json/urlinfo/data?url=%%URL%%
+ works
StumbleUpon:
http://www.stumbleupon.com/services/1.01/badge.getinfo?url=%%URL%%
+ works
Pinterest:
http://widgets.pinterest.com/v1/urls/count.json?source=6&url=%%URL%%
+ works
Vkontakte Shares:
http://vk.com/share.php?act=count&url=%%URL%%
+ works
Vkontakte Likes:
http://suvitruf.ru/2012/06/02/1255/
Odnoklassniki:
http://www.odnoklassniki.ru/dk?st.cmd=extOneClickLike&uid=odklocs0&ref=%%URL%%
+ works
Мой Мир Mail.ru:
http://connect.mail.ru/share_count?url_list=%%URL%%
+ works
Google+ counts are retrieved via a JSON-RPC POST call.
POST URL:
https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ
POST Body:
[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"%%URL%%","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]
or:
https://plusone.google.com/u/0/_/+1/fastbutton?count=true&url=%%URL%%
+ shows counter, you can parse html (div#aggregateCount)
$google_request = file_get_contents('https://plusone.google.com/u/0/_/+1/fastbutton?count=true&url='.$url);
$plusone_count = preg_replace('/(.*)<div id="aggregateCount" class="t1">(([0-9])*)<\/div>(.*)/is','$2',$google_request);
Reading:
http://www.tomanthony.co.uk/blog/google_plus_one_button_seo_count_api/
http://sergunik.name/?p=799
http://suvitruf.ru/2012/06/02/1255/
https://gist.github.com/jonathanmoore/2640302
@DonPramis
Copy link

@ElchinIsmayilov check please my code..still cant get a share from facebook

@caiobatis
Copy link

Hi, does anyone have a solution for the Twitter counter?

@1v
Copy link

1v commented Mar 4, 2018

ok.ru:

https://connect.ok.ru/dk?st.cmd=extLike&tp=json&ref=https://ya.ru/

@pagelab
Copy link

pagelab commented Aug 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment