通过 Facebook 阅读开放图图像 API

Read open graph image through Facebook API

这是 whosebug.com 的 og:image 元标记:

<meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/Whosebug/img/apple-touch-icon@2.png?v=ea71a5211a91&a" />

是否可以通过 Facebook 的 Open Graph API 读取此信息,而不是手动抓取页面?

https://graph.facebook.com/?id=http://stackoveflow.com returns:

{
  "og_object": {
    "id": "10150180465825637",
    "description": "Q&A for professional and enthusiast programmers",
    "title": "Stack Overflow",
    "type": "website",
    "updated_time": "2015-07-21T12:33:38+0000",
    "url": "http://whosebug.com/"
  },
  "share": {
    "comment_count": 4,
    "share_count": 32367
  },
  "id": "http://whosebug.com"
}

如果您另外请求 picture 字段,您应该会得到想要的结果:

/?id=http://whosebug.com&fields=id,share,og_object{id,title,type,updated_time,url,picture}

returns

{
  "id": "http://whosebug.com",
  "share": {
    "comment_count": 4,
    "share_count": 32367
  },
  "og_object": {
    "id": "10150180465825637",
    "title": "Stack Overflow",
    "type": "website",
    "updated_time": "2015-07-21T12:33:38+0000",
    "url": "http://whosebug.com/",
    "picture": {
      "data": {
        "is_silhouette": false,
        "url": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQA6I9bpNGiU11fN&w=200&h=200&url=http%3A%2F%2Fcdn.sstatic.net%2FWhosebug%2Fimg%2Fapple-touch-icon%402.png%3Fv%3Dea71a5211a91%26a&crop"
      }
    }
  }
}