Hey there! I'm trying to keep track of the number of likes on a specific URL shared by my friends. Here's the code snippet I have:
function countURLLikes(url){
FB.api({
access_token:'CAACEdEose0cBABMG67fV8Yn5cHo5fkb6kT6npRWO7YQL8zagoFLrz5OFLFIEPVUJhMwf9rql9oAqktDUJMKBGr5NNRXJ73jf418gspbfklvdJs6Kx1EkCRutYhSnSW4Binb4F9AlOUIHfXZC052SOdlgtxTSng6gM4CAZAstpLAoOd1p5pnCpNadnlluMqOxjHo1jx1QZDZD',
method: 'fql.multiquery',
queries: {
"query1":"SELECT total_count, like_count, click_count, normalized_url FROM link_stat WHERE url='"+url+"'",
"query2":"SELECT url FROM url_like WHERE user_id IN (SELECT uid1 FROM friend WHERE uid2 = me())"
}
}, function(response) {
console.log(response)
var urlLikes = 0;
var total = response[0].fql_result_set[0].total_count;
var likes = response[0].fql_result_set[0].like_count;
var clicks = response[0].fql_result_set[0].click_count;
var normalized_url = response[0].fql_result_set[0].normalized_url;
var results = response[1].fql_result_set
console.log('Total: ' +total+ ', Likes: ' + likes+ ', Clicks: ' +clicks)
console.log('Urls: ' + results.length)
console.log('=========================================================================')
console.log('Checking for url: ' + url);
console.log('=========================================================================')
for(var i = 0; i < results.length; i++){
var newUrl = decodeURI(url).toLowerCase();
var newFriendUrl = decodeURI(results[i].url).toLowerCase();
if (newUrl == newFriendUrl) {
urlLikes += 1;
}
}
console.log('Url likes: ' + urlLikes);
});
}
I am encountering an issue where, after my friend likes the URL from the second query, the counter does not increase. Instead, the URL is removed from the list. What could be the problem here?