Is there any API for fetching metadata of article using Facebook Open Graph Object Debugger?

南笙酒味 提交于 2020-08-12 02:59:06

问题


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

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

Example: Open Graph Object Debugger for Google

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


回答1:


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}

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.

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.

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!




回答2:


Yes you can use this https://urlmeta.org

Its usage is pretty simple. Just make a GET call and pass the URL to API endpoint: https://api.urlmeta.org and you are done.



来源:https://stackoverflow.com/questions/46516251/is-there-any-api-for-fetching-metadata-of-article-using-facebook-open-graph-obje

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!