Facebook Graph API - get ID for a URL?

后端 未结 6 886
小鲜肉
小鲜肉 2020-12-05 10:37

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

相关标签:
6条回答
  • 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

    0 讨论(0)
  • 2020-12-05 11:14

    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?

    0 讨论(0)
  • 2020-12-05 11:21

    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.

    0 讨论(0)
  • 2020-12-05 11:29

    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 讨论(0)
  • 2020-12-05 11:32

    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!

    0 讨论(0)
  • 2020-12-05 11:34

    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

    0 讨论(0)
提交回复
热议问题