Created
May 16, 2012 23:05
-
-
Save infynyxx/2714757 to your computer and use it in GitHub Desktop.
Using Facebook Graph API JS Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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