Created
May 18, 2012 11:24
-
-
Save kopiro/2724766 to your computer and use it in GitHub Desktop.
Get ID of Facebook by URL
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
getFBId = function(t) | |
{ | |
if (!window.jQuery) return; | |
var span = $('#fbid'); | |
var url = t.value; | |
span.text('Calcolo..'); | |
var id = url.match(/facebook\.com\/profile\.php\?id\=([0-9]*)/); | |
if (id) | |
{ | |
span.text(id[1]); | |
} | |
var usr = url.match(/facebook\.com\/([a-zA-Z0-9._-]*)/); | |
if (!usr) | |
{ | |
span.text('Errore!'); | |
return; | |
} | |
$.getJSON('http://graph.facebook.com/'+usr[1], function(r) | |
{ | |
if (!r) | |
{ | |
span.text('Errore!'); | |
return; | |
} | |
span.text(r.id); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment