Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API - get ID for a URL?

Tags:

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.

like image 404
Dusda Avatar asked Aug 27 '10 05:08

Dusda


People also ask

Is Facebook graph API deprecated?

API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.

How do I get my Facebook graph API User ID?

The simplest way to get a copy of the User Profile object is to access the /me endpoint: FB. api('/me', function(response) { }); This will this will return the users name and an ID by default.


2 Answers

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!

like image 60
Peter Gombos Avatar answered Sep 21 '22 01:09

Peter Gombos


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.

like image 44
KaKa Avatar answered Sep 18 '22 01:09

KaKa