2

I'm trying to retrieve Open Graph data for websites from Facebook.

I found a url that takes a website as a parameter and returns Facebook post information such as number of likes a page has gotten.

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

As nice as this is, I need the open graph information in the same JSON format to get the websites OG metatags.

There is this URL

I.E https://developers.facebook.com/tools/debug/og/object?q={URL}&format=json

that is supposed to return JSON but it's currently non functional and there is a bug filed here.

When you parse the URL through the online debugger.

There is a direct link at the bottom of the page that contains the exact information I'm looking for.

https://graph.facebook.com/380728101301

However I have no idea how to programmaticly get the ID (380728101301) for the URL match.

(Note that there are two separate calls for URLS, the first one (with ?ids=) I can get easily which gives the FB info such as number of likes. I need to get the 2nd one that mentions the OG metatags on the webpage).

Chamilyan
  • 9,347
  • 10
  • 38
  • 67

1 Answers1

1

you can use a fql query to retrieve the object id for a url. here is the PHP code for any url.

$fql = "SELECT url, id, type, site FROM object_url WHERE url = '{$url}'"; 
$param  =   array(
        'method'    => 'fql.query',
        'query'     => $fql,
        'callback'  => ''
    );
$result   =   $fb->api($param);

$result will return an array of url properties which includes the id.

ozgurky
  • 126
  • 1
  • 5
  • I think there is a bug. Because returning id for this query and facebook debugger tool's id for the same url are different. – ozgurky Mar 14 '12 at 09:42