ruby-oembed icon indicating copy to clipboard operation
ruby-oembed copied to clipboard

ProviderDiscovery does not work for WordPress

Open manuels opened this issue 14 years ago • 3 comments
trafficstars

The line of WordPress pages are not parsed correcty, I think. It states: <link rel="alternate" type="application/json+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=json&amp;url=https%3A%2F%2Fsweetandweak.wordpress.com%2F2011%2F09%2F23%2Fnothing-starts-the-morning-like-a-good-dose-of-panic%2F&amp;for=wpcom-auto-discovery"><link rel="alternate" type="application/xml+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=xml&amp;url=https%3A%2F%2Fsweetandweak.wordpress.com%2F2011%2F09%2F23%2Fnothing-starts-the-morning-like-a-good-dose-of-panic%2F&amp;for=wpcom-auto-discovery">

probably you just have to say provider_endpoint ||= /<link.*href=['"]*([^\s'"]+)['"]*.*application\/json\+oembed.*>/.match(res.body)[0] instead of provider_endpoint ||= /<link.*href=['"]*([^\s'"]+)['"]*.*application\/json\+oembed.*>/.match(res.body) in these lines: https://github.com/judofyr/ruby-oembed/blob/master/lib/oembed/provider_discovery.rb#L41

manuels avatar Sep 24 '11 22:09 manuels

Oh, yes: If you need a page for testing this. It did not work for me for this page: https://sweetandweak.wordpress.com/2011/09/23/nothing-starts-the-morning-like-a-good-dose-of-panic/

manuels avatar Sep 24 '11 22:09 manuels

After writing some tests for OEmbed::ProviderDiscovery I've discovered that this is (to some extent) WordPress's fault for not following the oEmbed specification. According to WordPress's API documentation their oEmbed endpoint requires a for parameter with each request. In its current state, OEmbed::ProviderDiscovery isn't intelligent enough to pass along extra parameters like for, and so WordPress returns an error.

All that to say, this is still an open issue, but at least it's an understood issue now and has some decent test coverage available once a fix is written.

metavida avatar Sep 25 '11 19:09 metavida

ok, good to know. Thanks for ruby-oembed, btw!

manuels avatar Sep 26 '11 21:09 manuels