Facebook Graph API - get ID for a URL?

橙三吉。 提交于 2019-11-27 20:07:41
KaKa

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 Gombos

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!

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?

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

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"
   }
}
marceloduende

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!