获取URL的Facebook ID

时间:2013-05-30 17:01:03

标签: php facebook api facebook-graph-api

我想知道如何检索输入URL时Open Graph Debugger显示的信息。

这是一个例子:我有一个页面包含所有正确的og meta标签,顶部看起来像这样:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta property="og:url" content="http://www.freefunder.com/campaign/Short-Film-Revenge-Inc/" />
<meta property="og:type" content="Website" />
<meta property="og:title" content="Short Film: &quot;Revenge, Inc.&quot;" />
<meta property="og:description" content="&quot;Revenge, Inc.&quot; is the first short film for the Karmalicity Movie Project. A feel-good story with a positive message." />
<meta property="og:image" content="http://www.freefunder.com/images/campaigns/2094_main.jpg" />
<meta property="fb:app_id" content="346433602097524" />

当我在Open Graph Debugger中查找它时,它为我提供了代码206并且没有错误,在底部它将为我提供使用Graph API查找此内容的URL,即:https://graph.facebook.com/103335396527655

我遇到的问题是我需要能够在我的代码中确定Facebook ID(103335396527655),而不是每次都要去调试器。如果我去:

http://graph.facebook.com/?ids=http://www.freefunder.com/campaign/Short-Film-Revenge-Inc/

它不会返回相同的信息(并且不包含ID),就像我转到调试器提供的Graph API URL一样。

有没有办法,给定一个特定的URL,为它查找正确的Facebook ID?这可以是Graph API,FQL,PHP SDK,等等!我只需要输入一个URL并获取它的Facebook ID ..

谢谢!

1 个答案:

答案 0 :(得分:1)

首先,只是因为页面有一个Like按钮而OG标签并不意味着FB Crawler曾经抓过该页面。如果该页面从未被“喜欢”,“共享”或已成为Open Graph操作的一部分,则Facebook不知道它存在,因此在graph.facebook.com上没有关于它的信息

其次,无法保证始终为相同的网址提供相同的图片ID。我试过做一种URL - &gt; ID映射事物(为了检查某个用户是否喜欢某个页面)过去和相同的确切URL可以与任意数量的不同ID相关。唯一可靠的结果将是Facebook页面和用户个人资料。

所以,你需要的是使用phpQuery这样的东西,然后去寻找你想要确保存在于用户页面上的任何标签。

相关问题