Skip to content

Instantly share code, notes, and snippets.

@rumkin
Last active October 12, 2015 02:18
Show Gist options
  • Save rumkin/3956207 to your computer and use it in GitHub Desktop.
Save rumkin/3956207 to your computer and use it in GitHub Desktop.
Count facebook likes
function fbQuery(url)
{
var fql = 'SELECT share_count FROM link_stat WHERE url="' + url + '"'
, fbUrl = 'https://api.facebook.com/method/fql.query?format=json&query=';
return fbUrl + encodeURIComponent(fql)
}
function vkQuery(url)
{
var reqUrl = 'http://vkontakte.ru/share.php?act=count&url=';
return reqUrl + encodeURIComponent(url)
}
function twQuery(url)
{
var reqUrl = 'http://urls.api.twitter.com/1/urls/count.json?url=';
return reqUrl + encodeURIComponent(url)
}
function xhr(url){
var xhr = new XMLHttpRequest(url);
xhr.open('GET', url, false); xhr.send(null);
if (xhr.status == 200) {
return xhr.responseText;
} else {
console.log('Error: %s %s', xhr.status, xhr.responseText);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment