Andrea Gianfreda
Andrea Gianfreda

Reputation: 35

Getting Open Graph object ID from page URL

how can I get the Facebook Object ID paired to a page from the page itself?

For example, I asked directly for the Object ID 325186347604922 and i got:

<pre>
{
  "url": ".../ricetta-bigne_salati.htm", 
  "type": "ricettepercucinare:recipe", 
  "title": "Bignè salati", 
  "image": [
    {
      "url": ".../magazine/wp-content/uploads/2013/03/101-150x150.jpg", 
      "width": 150, 
      "height": 150
    }
  ], 
  "description": "Gli ingredienti e la procedura per preparare la ricetta Bignè salati.", 
  "data": {
    "course": "Antipasto", 
    "foreign_id": 130400
  }, 
  "updated_time": "2013-03-28T10:12:17+0000", 
  "id": "325186347604922", 
  "application": {
    "id": "118665634826424", 
    "name": "Ricettepercucinare.com", 
    "url": "https://www.facebook.com/apps/application.php?id=118665634826424"
  }
}</pre>

But how, for example, this page http://www.ricettepercucinare.com/ricetta-bigne_salati.htm could know its own ID?

Thank you.

Upvotes: 3

Views: 2902

Answers (3)

Alexandre Testu
Alexandre Testu

Reputation: 433

It's possible with FQL:

select id, url from object_url where url in ('http://www.watchth.is/movies/9166-baraka')

See it in the Graph API Explorer, or simply use this ajax call: https://graph.facebook.com/fql?q=select%20id%2C%20url%20from%20object_url%20where%20url%20in%20('http%3A%2F%2Fwww.watchth.is%2Fmovies%2F9166-baraka')&format=json&suppress_http_code=1

Thanks to Rees' response to a similar question

Upvotes: 0

N D
N D

Reputation: 737

What about this guy's solution: http://blog.odbol.com/?p=9

function facebookGetIdForUrl(url, callback) {
  //see http://developers.facebook.com/docs/reference/fql/object_url/
  FB.api({
    method: 'fql.query',
    query: "SELECT id FROM object_url WHERE url = '" + url + "'"
  }, function(response) {
    callback(response[0].id);
  });
}

facebookGetIdForUrl("http://facebook.com", function (id) {
  alert("Facebook ID = " + id);
});

Upvotes: 0

Simon Cross
Simon Cross

Reputation: 13345

Its not currently possible to look up an object ID from the URL - although it should be.

It should be possible using:

http://graph.facebook.com/?id=http://www.ricettepercucinare.com/ricetta-bigne_salati.htm

but this isn't working.

Please raise a bug at developers.facebook.com/bugs

Upvotes: 1

Related Questions