Skip to content

Instantly share code, notes, and snippets.

@saippuakauppias
Last active September 22, 2021 12:41
Show Gist options
  • Save saippuakauppias/4528686 to your computer and use it in GitHub Desktop.
Save saippuakauppias/4528686 to your computer and use it in GitHub Desktop.
Get shares counts from social networks
$(document).ready(function() {
var location = document.location.href;
// fb
$.getJSON(
"http://graph.facebook.com/" + location + "&callback=?",
function(data) {
if(data.shares == undefined) {fb_shares = 0} else {fb_shares = data.shares}
$("#fb_soc_counter").html(fb_shares);
}
);
// vk
VK = {}
VK.Share = {};
VK.Share.count = function(index, count){
$("#vk_soc_counter").html(count);
};
$.getJSON("http://vkontakte.ru/share.php?act=count&index=1&url=" + location + "&format=json&callback=?");
// twitter
$.getJSON(
"http://urls.api.twitter.com/1/urls/count.json?url=" + location + "&callback=?",
function(data) {
$("#twitter_soc_counter").html(data.count);
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment