Facebook Graph API - 获取 URL 的 ID?

发布于 2024-09-16 08:41:41 字数 775 浏览 8 评论 0原文

这似乎是 Graph API 中非常明显、基本的事情,但我'我对此有严重的困难。我想做的就是获取任何特定 URL 的 ID。他们有一个方法:

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

而且效果很好。但是,如果我尝试另一个 URL(例如我的博客),

https://graph.facebook.com/?ids=http://dusda.vox.com

它不会像所有示例那样返回数字 ID。相反,这样:

{"http:\/\/dusda.vox.com":{"id":"http:\/\/dusda.vox.com"}}

如果我尝试使用该“id”,我会得到 jack (可能是因为查询字符串看起来无法解析):

Request: https://graph.facebook.com/http://dusda.vox.com/likes
Response: {"id":"http:\/\/dusda.vox.com\/likes"}

那么这是怎么回事? Graph API 只是选择性可靠,还是我误解了什么?我已经在我知道 Facebook 上也很流行的 URL 上进行了尝试,结果好坏参半。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

兔姬 2024-09-23 08:41:41

尝试使用 FQL

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

返回:

{
   "data": [
      {
         "url": "http://kriek.hu/",
         "id": 497425470154,
         "type": "link",
         "site": "kriek.hu"
      }
   ]
}

有关详细信息,请参阅object_url

我希望它有帮助!

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!

ˉ厌 2024-09-23 08:41:41

Facebook 仅向具有 fbshare/like 按钮的页面提供 ID。否则,API 将返回共享数量和请求 URL。

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.

无语# 2024-09-23 08:41:41

如果我使用 facebook 对象调试器页面,我可以抓取每个 url,例如:

https://developers.facebook.com/tools/debug/og/object?q=ddnl.de

该页面给我返回一个带有 ID 的 url,这样我就可以获得所有需要的参数。

在这种情况下 https://graph.facebook.com/10150164108649475

但我没有得到这个 ID 或者url 带有 FQL 还是其他?

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?

梦屿孤独相伴 2024-09-23 08:41:41

非常老的问题,但我发现这对我有用,因为这里的答案都没有真正解决我的问题:

如果您有一个绑定到 url 的自定义对象,则 Pepe 建议的方法仅给出 id FB 分配给 url 的类型=链接。 (与任何评论无关)

就我而言,我需要自定义对象 ID,以便我可以从中提取相关评论。您可以通过从“link_stat”表中选择“comments_fbid”,使用 FQL 获取对象 ID。 (即使没有添加评论,这也会返回对象 ID,因此它应该适用于其他情况)

api.facebook.com

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

雨后咖啡店 2024-09-23 08:41:41

目前,所有建议的解决方案均不适用于所有网址。只有调试器才能正确获取图形 ID

例如

调试器:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.amazon.de%2Fgp%2Fproduct%2F3810510793%2F

对于 URL:
www.amazon.de/gp/product/3442465583/

结果:
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"
   }
}

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"
   }
}
素衣风尘叹 2024-09-23 08:41:41

我在这里遇到了同样的问题,我试图获取 IMDB 获取的相同数据。差点把头撞到墙上后,我决定看看facebook的js函数。看看我得到了什么,解释在链接上。

从页面获取有限数据拥有 Facebook ID

Peace

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文