WordPress refuses to show oembed URL

I need WP to show an embedded representation of a url such as http://domain.com/1121 using oembed.

I have setup http://domain.com/1121 with a discovery link:

<link href="http://www.domain.com/generator/oembed/?url=http%3A//domain.com/1121" rel="alternate" type="text/xml+oembed" />

I’m aware that WP no longer automatically discovers embeddable URLs, so I installed enable-oembed-discovery plugin to re-enable this feature.

I have monitored my apache logs and confirmed that WP does hits the link to discover – so I guess the enable-oembed-discovery plugin works, but the URL is NEVER converted.

I even wrote a plugin to whitelist my custom URL (really should not be needed since enable-oembed-discovery plugin should enable auto-discovery, but what the heck):

add_action( 'init', 'my_oembed_provider' );

function my_oembed_provider() {
    wp_oembed_add_provider( 'http://domain.com/*', 'http://www.domain.com/generator/oembed/', false);
}

and still nothing.

The API endpoint (http://www.domain.com/generator/oembed/) is hard coded to generate the following XML:

        <?xml version="1.0" encoding="UTF-8"?>
        <OEmbed>
            <type>rich</type>
            <width>400</width>
            <height>342</height>
            <html><![CDATA[&lt;b&gt;HELLO WORLD FROM OEMBED &lt;/b&gt;]]></html>
        </OEmbed>

The API endpoint sends the right content-type header (header("Content-type: text/xml");) as required by the oembed spec

The user adding the post has admin privileges and therefore is allowed unfiltered_html

I’m out of ideas and at wit’s end. What am I missing?

2 Answers
2

Your XML root element was ‘OEmbed’, not ‘oembed’, as given in the spec. XML element names are case-sensitive, per the XML spec.

Leave a Comment