20

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dusda
  • 3,347
  • 5
  • 37
  • 58
  • Old question, still no solution? I tried cnn.com, works fine in the debugger, but does not return the ID using the API... – Nathan H Apr 24 '14 at 15:41

6 Answers6

10

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!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Peter Gombos
  • 101
  • 1
  • 4
8

The ID is given by Facebook only to pages which have a fbshare/like button. Else the API returns the number of shares and the request URL.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
KaKa
  • 1,543
  • 12
  • 18
  • 4
    https://graph.facebook.com/?id=http://www.huffingtonpost.com/2011/06/14/new-york-mercatus-center-least-free-state_n_876616.html has a Like button but the link still gives back limited information. Both pages has a fb:app_id in the section. – karatedog Jun 16 '11 at 09:49
  • 1
    Is this behaviour documented somewhere? – Hugo Tunius Mar 19 '14 at 10:17
4

If I use the facebook object debugger page I can scrape every url, for example:

https://developers.facebook.com/tools/debug/og/object?q=ddnl.de

The page give me back an url with ID and so I can get every needed parameters.

In this case https://graph.facebook.com/10150164108649475

But I don't get this ID or url with FQL or otherwise?

Tony
  • 41
  • 1
3

Very old question, but here's what I found works for me as none of the answers here really resolved my issue:

If you have a custom object tied to a url, the method suggested by Pepe only gives the id FB assigns to the url where type=link. (Which is not tied to any comments)

In my case, I need my custom object id so that I could pull associated comments from it. You can get the object id using FQL by doing a select on 'comments_fbid' from the 'link_stat' table. (This will return the object id even if no comments have been added so it should work for other cases)

api.facebook.com

Warren Kim
  • 306
  • 3
  • 4
2

At this time no of the suggested solutions work for all urls. Only the Debugger is able to get the Graph ID correctly

For example

Debugger: https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.amazon.de%2Fgp%2Fproduct%2F3810510793%2F

For URL: www.amazon.de/gp/product/3442465583/

Result: https://graph.facebook.com/10150771435736113

{
   "url": "http://www.amazon.de/dp/3810510793/ref=tsm_1_fb_lk",
   "type": "book",
   "title": "Die unwahrscheinliche Pilgerreise des Harold Fry: Roman",
   "image": [
      {
         "url": "http://ecx.images-amazon.com/images/I/51I4E81xrRL._SL160_.jpg"
      }
   ],
   "description": "Die unwahrscheinliche Pilgerreise des Harold Fry: Roman",
   "site_name": "Amazon.de",
   "updated_time": "2012-12-19T16:54:27+0000",
   "id": "10150771435736113",
   "application": {
      "id": "164734381262",
      "name": "Amazon",
      "url": "https://www.facebook.com/apps/application.php?id=164734381262"
   }
}
0

I had the same problem here, I was trying to get the same data IMDB gets. After almost bang my head against the wall, I decided to look at the facebook's js function. And look what I get, the explanation is on the link.

Getting limited data from a page which has a Facebook ID

Peace

Community
  • 1
  • 1
marceloduende
  • 719
  • 2
  • 6
  • 15