Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created May 16, 2012 23:05
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 infynyxx/2714757 to your computer and use it in GitHub Desktop.
Save infynyxx/2714757 to your computer and use it in GitHub Desktop.
Using Facebook Graph API JS Object
var logFB = function(url) {
var login_status, _data, _fb, _get_share_count2;
if (url == null) url = false;
if (url === false) url = window.location.href;
_data = {};
_get_share_count2 = function(url, callback) {
var params;
if (typeof window.FB !== 'undefined') {
window.FB.api('/', {
id: url
}, function(response) {
if (response['shares'] !== 'undefined') {
return callback(response['shares']);
}
});
} else {
params = {
url: 'https://graph.facebook.com/?id=' + encodeURIComponent(url),
async: false,
success: function(response) {
if (response['shares'] !== 'undefined') {
return callback(response['shares']);
}
}
};
$.ajax(params);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment