且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有用于使用Facebook Open Graph Object Debugger提取文章元数据的API?

更新时间:2022-02-20 22:44:07

是的,通过此处.请注意,您可以对此URL发出POST请求以强制刷新.您甚至可以获取其他数据,例如该链接在Facebook上共享了多少次!

Yes, via the API URL Object described here and in even more detail here. Note that you can issue a POST request to this URL to force a refresh. You can even get additional data such as how many times that link was shared on Facebook!

https://graph.facebook.com/v2.10/?fields=og_object&id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F&access_token={YOUR_TOKEN}

我确实遇到了不一致的情况,即如果对象不存在,则API将不返回任何内容,但是如果您在几秒钟后对其进行查询,则该API将在那里.因此,我们不能依靠Facebook,而是自己获取页面并解析出og:*标签.

I did experience inconsistencies, namely if the obejct does not exist the API will return nothing but if you query it a few seconds later it will be there. For this reason we could not rely on Facebook and simply fetched the page ourselves and parsed out the og:* tags.

如果您不关心未命中和必须重新获取数据,或者只想以编程方式清除Facebook OG缓存,那可能是完美的选择.

It may be perfect if you don't care about misses and having to re-fetch or if you just want to programmatically clear the Facebook OG cache.

每次创建一个新页面以强制缓存,或者有时第一个将URL粘贴到Facebook的人都不会获得链接预览的情况下,***将其张贴到页面上!

It's wise to post to it every time you create a new page to force the cache or sometimes the first person to paste the URL into Facebook won't get the link preview!