我怎样才能获得 oembed json 的 reddit 评论?

How can I get oembed json for reddit comment?

我正在尝试使用 python-oembed 库从 reddit (https://github.com/reddit/reddit/wiki/oEmbed) 获取 oembed 评论:

import oembed

consumer = oembed.OEmbedConsumer()
endpoint = oembed.OEmbedEndpoint('https://www.reddit.com/oembed',['https://www.reddit.com/r/*'])

consumer.addEndpoint(endpoint)

response = consumer.embed('https://www.reddit.com/r/Showerthoughts/comments/2safxv/we_should_start_keeping_giraffes_a_secret_from/cno7zic')

并得到 oembed.OEmbedError: Missing required fields on OEmbed rich response. 错误。

如何检索这些数据?

reddit返回的oembed无效

http://oembed.com/ 开始,rich 类型需要 §2.3.4.4、widthheight

但是,从 the reddit sample,我们看到 reddit 没有提供 widthheight 值。

您可能需要获取 reddit 来修复他们损坏的 oembed 实现,或者您可能想使用更宽容的库。