Quick edits to replace links.
I would like to add the total shares of 4 pages together. Someone made this for me and I cleaned it up a bit with some help. All works but now I want to add the total likes for four pages and I’m hoping I could get a little help here?
function fbs_click() {
u = location.href;
t = document.title;
window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
return false;
}
// THE FOUR URL'S TO ADD THE TOTAL SHARES
var Gal_All = "Original URL here";
var Gal_S_1 = "Second URL here";
var Gal_S_2 = "Third URL here";
var Gal_S_3 = "Fourth URL here";
var tweets;
function getTwitterCount(url) {
$.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + url + '&callback=?', function(data) {
tweets = data.count;
$('#twitterCount').html(tweets);
showTotal();
});
}
var urlBase = 'Original URL is here now as var';
getTwitterCount(urlBase);
$.ajax({
type: 'GET',
url: 'https://graph.facebook.com/ + Original URL is here now as var',
success: function(data) {
showCount(data);
}
});
var fbshares;
var fbcomments;
function showCount(responseText) {
// Save the parsed JSON
var json = responseText;
// A shares property and value must exist, update
// the span element with the share count
fbshares = json.shares;
fbcomments = json.comments;
$('#fb-share-count').html(fbshares);
if (fbcomments) {
$('#TotalComments').html(fbcomments + ' comments');
}
showTotal();
}
function showTotal() {
if (tweets !== undefined && fbshares !== undefined)
$('#total-share-count').html(tweets + fbshares);
}
Obviously you can ignore the Facebook adding four pages due to where I’m asking for help - I believe I can do this part but I don’t quite understand the Twitter part…
Best Regards,
Tim