Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Social Share Count using the JSON API's
$.getJSON("http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=?", function(data) {
if ((data.count != 0) && (data.count != undefined) && (data.count != null)) {
$("#twbutton").addClass('hascount');
$("#twbutton").after('<a class="button count"><span>'+data.count+'</span></a>');
}
});
$.getJSON("https://graph.facebook.com/%%URL%%&callback=?", function(data) {
if ((data.shares != 0) && (data.shares != undefined) && (data.shares != null)) {
$("#fbbutton").addClass('hascount');
$("#fbbutton").after('<a class="button count"><span>'+data.shares+'</span></a>');
}
});
$.getJSON("http://api.pinterest.com/v1/urls/count.json?url=%%URL%%&callback=?", function(data) {
if ((data.count != 0) && (data.count != undefined) && (data.count != null)) {
$("#pinbutton").addClass('hascount');
$("#pinbutton").after('<a class="button count"><span>'+data.count+'</span></a>');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.