Facebook Graph API – Get ID from Facebook Page URL

It seems to me that the easiest solution to what you describe is to just get the id/name from the url you have using lastIndexOf(“https://stackoverflow.com/”) (which most languages have an equivalent for) and then get “https://graph.facebook.com/” + id.

The data that this url returns has the id (i.e.: 6708787004) and the username (i.e.: southpark), so regardless of which identifier you use (what you extract from the url using lastIndexOf), you should get the same result.


Edit

This code:

identifier = url.substring(url.lastIndexOf("https://stackoverflow.com/"))
graphUrl = "https://graph.facebook.com/" + identifier
urlJsonData = getGraphData(graphUrl)

Should work the same (that is result with the same data) for both:

url = http://www.facebook.com/southpark

And

url = http://www.facebook.com/6708787004

(you’ll obviously need to implement the getGraphData method).

Also, the 2nd url form in the question is not a valid url for pages, at least not from my tests, I get:

You may have clicked an expired link or mistyped the address. Some web
addresses are case sensitive.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)