是否有用于使用Facebook Open Graph Object Debugger提取文章元数据的API? [英] Is there any API for fetching metadata of article using Facebook Open Graph Object Debugger?

查看:89
本文介绍了是否有用于使用Facebook Open Graph Object Debugger提取文章元数据的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Facebook Open Graph Object Debugger来获取任何网页的元数据.

I want to fetch metadata of any web-page using Facebook Open Graph Object Debugger.

我们可以从以下URL获取它:打开图形对象调试器

We can get it from this URL: Open Graph Object Debugger

示例:它将提供与该URL相关的所有信息.有什么方法可以使用API​​(JSON格式)获取此信息?

It will provide all the information related to that URL. Is there any way to get this information using API(in JSON format)?

推荐答案

是的,通过

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!

这篇关于是否有用于使用Facebook Open Graph Object Debugger提取文章元数据的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆