Facebook Graph API - get ID for a URL?

Dusda picture Dusda · Aug 27, 2010 · Viewed 38.4k times · Source

This seems like a pretty obvious, basic thing to expect from the Graph API, but I'm having serious difficulty with it. All I want to do is get the ID for any particular URL. They have a method for this:

https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/

And that works great. But if I try another URL, say for my blog,

https://graph.facebook.com/?ids=http://dusda.vox.com

it doesn't give me back a numerical ID like all of the examples do. Instead, this:

{"http:\/\/dusda.vox.com":{"id":"http:\/\/dusda.vox.com"}}

If I try to use that "id", I get jack (probably because the query string looks impossible to parse):

Request: https://graph.facebook.com/http://dusda.vox.com/likes
Response: {"id":"http:\/\/dusda.vox.com\/likes"}

So what's up with this? Is the Graph API just selectively reliable, or am I misunderstanding something? I've tried it on URLs that I know are popular on Facebook, too, and I've gotten mixed results.

Answer

Peter Gombos picture Peter Gombos · Jan 3, 2012

Try FQL for this;

http://graph.facebook.com/fql?q=select%20url%2C%20id%2C%20type%2C%20site%20from%20object_url%20where%20url%20%3D%20%22http%3A%2F%2Fkriek.hu%2F%22

returns:

{
   "data": [
      {
         "url": "http://kriek.hu/",
         "id": 497425470154,
         "type": "link",
         "site": "kriek.hu"
      }
   ]
}

For more information, see object_url.

I hope it helps!