Skip to content

Instantly share code, notes, and snippets.

@samsargent
Created November 14, 2012 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsargent/4069978 to your computer and use it in GitHub Desktop.
Save samsargent/4069978 to your computer and use it in GitHub Desktop.
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