【问题标题】:Getting Open Graph object ID from page URL从页面 URL 获取 Open Graph 对象 ID
【发布时间】:2013-04-02 19:54:06
【问题描述】:

如何从页面本身获取与页面配对的 Facebook 对象 ID?

例如,我直接询问对象 ID 325186347604922,我得到:

<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>

但是,例如,这个页面http://www.ricettepercucinare.com/ricetta-bigne_salati.htm 是如何知道它自己的 ID 的呢?

谢谢。

【问题讨论】:

  • 为什么需要身份证?你不能互换使用网址吗?
  • 我需要它,因为我想验证,当用户在特定页面中时,该对象是否包含在以前的活动中(为了符合 Open Graph 条款,将其读作“故事") 由用户使用它完成。
  • 同样的问题,你不能用这个ID吗?
  • 我在网站上管理的不是 Facebook 对象 ID,而是 URL。我需要知道的是提供 URL 的对象 ID。感谢您的支持。

标签: javascript json facebook-opengraph


【解决方案1】:

目前无法从 URL 中查找对象 ID - 尽管应该可以。

应该可以使用:

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

但这不起作用。

请在 developers.facebook.com/bugs 上提出错误

【讨论】:

    【解决方案2】:

    这家伙的解决方法呢: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);
    });
    

    【讨论】:

    • 添加代码示例或更多解释会很好。
    【解决方案3】:

    使用 FQL 是可能的:

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

    See it in the Graph API Explorer,或者直接使用这个ajax调用: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')&amp;format=json&amp;suppress_http_code=1

    Thanks to Rees' response to a similar question

    【讨论】:

      猜你喜欢
      • 2012-04-26
      • 2016-04-01
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-22
      • 1970-01-01
      相关资源
      最近更新 更多