Search code examples
facebook

Facebook ID from URL


Given a facebook url such as http://facebook.com/cnn, is there any way to get the ID of that page short of scraping it?


Solution

  • It is better (and legal) to do this with graph API. Just perform API request to https://graph.facebook.com/cnn and get id from the response.

    Here is the response for cnn:

    {
       "id": "5550296508",
       "name": "CNN",
       "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs178.ash2/41813_5550296508_728_s.jpg",
       "link": "http://www.facebook.com/cnn",
       "category": "Company",
       "website": "www.cnn.com\nwww.ireport.com\n",
       "username": "cnn",
       "company_overview": "TRIVIA FROM THE CNN TOUR...",
       "products": "CNN US...",
       "likes": 1689936
    }