<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    >

<channel>
    <title>Webmonkey &#187; oembed</title>
    <atom:link href="http://www.webmonkey.com/tag/oembed/feed/" rel="self" type="application/rss+xml" />
    <link>http://www.webmonkey.com</link>
    <description>The Web Developer&#039;s Resource</description>
    <lastBuildDate>Fri, 05 Apr 2013 20:20:46 +0000</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>http://wordpress.org/?v=3.4.2</generator>
    
    <item>
        <title>Getting Started With Twitter&#8217;s Embedded Tweets Feature</title>
        <link>http://www.webmonkey.com/2011/12/getting-started-with-twitters-embedded-tweets-feature/</link>
        <comments>http://www.webmonkey.com/2011/12/getting-started-with-twitters-embedded-tweets-feature/#comments</comments>
        <pubDate>Fri, 09 Dec 2011 17:43:48 +0000</pubDate>

                <dc:creator>Scott Gilbertson</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=53121</guid>
        		<category><![CDATA[APIs]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[oembed]]></category>
		<category><![CDATA[Twitter]]></category>
            <enclosure url="http://www.webmonkey.com/wp-content/uploads/2011/12/embedtweet.jpg" type="image/jpeg" length="48000" />
                    <description><![CDATA[<div class="rss_thumbnail"><img src="http://www.webmonkey.com/wp-content/uploads/2011/12/embedtweet.jpg" alt="Getting Started With Twitter&#8217;s Embedded Tweets Feature" /></div>Somewhat lost amidst the news of Twitter&#8217;s revamped interface is a slightly more interesting tidbit for web developers: Twitter posts can now be embedded in other pages. The new Embedded Tweet feature works just like a YouTube movie, offering a short HTML snippet that you can copy and paste into any third-party website. Unfortunately using [...]]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><div id="attachment_53126" class="wp-caption aligncenter" style="width: 590px"><a href="http://www.webmonkey.com/wp-content/uploads/2011/12/embedtweet.jpg"><img src="http://www.webmonkey.com/wp-content/uploads/2011/12/embedtweet.jpg" alt="" title="embedtweet" width="580" height="333" class="size-full wp-image-53126" /></a><p class="wp-caption-text">Embed a tweet in any webpage</p></div>Somewhat lost amidst the news of Twitter&#8217;s revamped interface is a slightly more interesting tidbit for web developers: Twitter posts can now be <a href="https://dev.twitter.com/docs/embedded-tweets">embedded in other pages</a>. </p>
<p>The new Embedded Tweet feature works just like a YouTube movie, offering a short HTML snippet that you can copy and paste into any third-party website. Unfortunately using the Embed Tweet feature from Twitter is somewhat awkward since it&#8217;s buried in the new interface. First you need to click on a tweet, then click &#8220;details&#8221; and then you&#8217;ll see the embed option. </p>
<p>The real benefit of the embed feature lies with third party platforms like Twitter&#8217;s two launch partners WordPress and Posterous. Users of both services can now simply paste a link to a tweet and it will automatically be converted to an embedded tweet, no cut and paste necessary. For example, just drop this code in your WordPress.com blog and it will automatically be converted to an embedded tweet:</p>
<pre class="brush:js">
[tweet https://twitter.com/twitterapi/status/133640144317198338]
</pre>
<p>If you&#8217;d like to implement something similar on your own site Twitter now has an <a href="http://oembed.com/">OEmbed</a> endpoint you can query to convert Twitter links to embedded tweets. Those not familiar with OEmbed can check out our <a href="http://www.webmonkey.com/2010/02/get_started_with_oembed/">OEmbed tutorial</a>, but, in a nutshell, OEmbed is a standard format where you send a URL and the host site then sends back the necessary embed code.</p>
<p>There are three steps to Twitter&#8217;s OEmbed process:</p>
<ol>
<li>Obtain an URL to or ID number of the Tweet you want to render.</li>
<li>Make a request to the GET statuses/oembed endpoint, passing the Tweet URL or ID as a query parameter.</li>
<li>Render the html property of the response, as well as a &lt;script&gt; element pointing to //platform.twitter.com/widgets.js, if you want the embed to be interactive.</li>
</ol>
<p>If you choose to render the tweet using Twitter&#8217;s widgets.js, the raw HTML will be converted into an interactive tweet. The fancy embedded tweet script uses <a href="http://webintents.org/">Web Intents</a> to allow users to reply, retweet, or follow the user directly from the embedded tweet. See the <a href="https://dev.twitter.com/docs/embedded-tweets">Twitter developer site</a> for more details on Twitter&#8217;s widgets.js and how to use OEmbed to embedded tweets to your website.</p>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2011/12/getting-started-with-twitters-embedded-tweets-feature/feed/</wfw:commentRss>
        <slash:comments>0</slash:comments>

        
    </item>
    
    <item>
        <title>Get Started With OEmbed</title>
        <link>http://www.webmonkey.com/2010/02/get_started_with_oembed/</link>
        <comments>http://www.webmonkey.com/2010/02/get_started_with_oembed/#comments</comments>
        <pubDate>Tue, 16 Feb 2010 01:45:47 +0000</pubDate>

                <dc:creator>Webmonkey Staff</dc:creator>

        <guid isPermaLink="false">http://stag.wired.com/primate/?p=957</guid>
        		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[oembed]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wiki]]></category>
        <description><![CDATA[Anyone with a blog will tell you: the best thing about the social media sharing revolution is the &#8220;sharing&#8221; part. Popular sharing sites like YouTube, Photobucket and Last.fm offer embed codes, strings of code that make it easy for you to plug a video or a song (inside a small player or display wrapper) into [...]]]></description>

            <content:encoded><![CDATA[<!-- wpautop disabled --><p>Anyone with a blog will tell you: the best thing about the social media sharing revolution is the &#8220;sharing&#8221; part.

</p><p>Popular sharing sites like YouTube, Photobucket and Last.fm offer embed codes, strings of code that make it easy for you to plug a video or a song (inside a small player or display wrapper) into your page. These codes work great for sites that offer them, but embed codes and options for embedding media differ greatly from site to site. And some sites don&#8217;t offer any easy sharing codes.

</p><p>It&#8217;s easy enough to post an image or MP3 if you know some HTML. But by now we&#8217;re deep into the age of the big &#8220;share&#8221; button &#8212; blog tools and widgets that offer no-brainer, one-click posting. So if you&#8217;re building a social app that allows users to share images, videos or songs, your visitors will expect something that&#8217;s as dead easy as it gets.

</p><p>To that end, what if there was a standard for grabbing a full multimedia embed code from a URL? Wouldn&#8217;t it be nice if you could turn a simple URL link into an embedded Flickr image or YouTube video? Sure, you can reverse engineer many of the various embed structures offered by sharing sites, but what happens when the host of your embeded media changes its format or relocates the actual asset? Thousands of broken links suddenly litter your site.

</p><p>These are the wishes (and problems) that led to OEmbed, a new proposed standard for taking a URL and generating an embed link. The proposal is the brainchild of Pownce developers Leah Culver and Mike Malone, as well Cal Henderson of Flickr and Richard Crowley of OpenDNS.

</p><p>Not every site supports it, so OEmbed isn&#8217;t going to solve all your embedding needs overnight. But given that some big names &#8212; like Flickr and Viddler &#8212; have already signed on, we think others will soon follow suit.

</p><p>Let&#8217;s dive in to see how OEmbed can make your life (and your webapp) easier.

</p><span id="more-957"></span><p><br />

</p>

<table id="toc" class="toc" summary="Contents"><tbody><tr><td><div id="toctitle"><h2>Contents</h2> </div>

<ol>

<li><a href="#An_OEmbed_Overview">An OEmbed Overview</a></li>

<li><a href="#Using_OEmbed">Using OEmbed</a></li>



<li><a href="#Getting_more_complex">Getting more complex</a>

<ol>

<li><a href="#Security_Note">Security Note</a></li>

</ol>

</li>

<li><a href="#Sky.27s_the_Limit">Sky&#8217;s the Limit</a></li>

<li><a href="#Why_We_Love_OEmbed">Why We Love OEmbed</a></li>



</ol>

</td></tr></tbody></table>



<a name="An_OEmbed_Overview"></a><h2> <span class="mw-headline">An OEmbed Overview</span></h2>

<p>Put simply, OEmbed dictates a standard format where you send a URL and the host site provides the embed code. In the simplest case, you would capture the URL your user has entered and then query the originating service&#8217;s API to get back any additional info you need.

</p><p>Here&#8217;s how it works: The user enters a URL, the service (say Pownce) then queries the source of the URL (say, Flickr). The source site then sends back all the necessary information for Pownce to embed the image automatically.

</p><p>The full OEmbed spec says that all requests sent to the API endpoint (Flickr in our example) must be HTTP GET requests, with any arguments sent as query parameters. Obviously any arguments you send through HTTP should be url-encoded (as per <a href="http://www.faqs.org/rfcs/rfc1738.html" class="external text" title="http://www.faqs.org/rfcs/rfc1738.html" rel="nofollow">RFC 1738</a> in this case).

</p><p>The following query parameters are defined as part of the spec:

</p>

<ul><li> url (required) &#8211; The URL to retrieve embedding information for

</li><li> maxwidth (optional) &#8211; the maximum width of the embedded resource



</li><li> maxheight (optional) &#8211; the maximum height of the embedded resource

</li><li> format (optional) &#8211; the required response format (i.e. XML or JSON)

</li></ul>

<p>The maxwidth, maxheight parameters are nice when you&#8217;re embedding content into a fixed-width design and you don&#8217;t want to end up with embeds that turn your carefully designed site into some horrible-looking MySpace page.

</p><p>As for the response you get back from an OEmbed call, that will depend somewhat on what type of object you&#8217;re interested in embedding. In general you can expect things like the type of object, the owner of the content, thumbnails and more. For full details check out the <a href="http://OEmbed.com/" class="external text" title="http://OEmbed.com/" rel="nofollow">OEmbed site</a>.

</p>

<a name="Using_OEmbed"></a><h2> <span class="mw-headline">Using OEmbed</span></h2>

<p>Let&#8217;s say you&#8217;ve built a content sharing site like FriendFeed. I join your site and want to post <a href="http://www.flickr.com/photos/luxagraf/137254255/" class="external text" title="http://www.flickr.com/photos/luxagraf/137254255/" rel="nofollow">this Flickr image of the Himalayas</a> using just the URL. I cut and paste the URL from my browser window to your text field and then you would query Flickr using this code:



</p>

<pre class="brush: js">http://www.flickr.com/services/oembed/?url=http%3A//www.flickr.com/photos/luxagraf/137254255/

</pre>

<p>The XML response you would get back looks like this:

</p>

<pre class="brush: js">&lt;OEmbed&gt;

	&lt;version&gt;1.0&lt;/version&gt;

	&lt;type&gt;photo&lt;/type&gt;



	&lt;title&gt;Nepal-Sarangkot_12_16_05_31&lt;/title&gt;

	&lt;author_name&gt;luxagraf&lt;/author_name&gt;

	&lt;author_url&gt;http://www.flickr.com/photos/luxagraf/&lt;/author_url&gt;

	&lt;cache_age&gt;3600&lt;/cache_age&gt;



	&lt;provider_name&gt;Flickr&lt;/provider_name&gt;

	&lt;provider_url&gt;http://www.flickr.com/&lt;/provider_url&gt;

	&lt;width&gt;375&lt;/width&gt;

	&lt;height&gt;500&lt;/height&gt;



	&lt;url&gt;http://farm1.static.flickr.com/50/137254255_008f50c357.jpg&lt;/url&gt;

&lt;/OEmbed&gt;

</pre>

<p>As you can see, all you need to do is grab the <code>url</code> and plug that into a standard <code>img</code> tag and my photo will show up without me having to do any extra work at all.

</p><p>And I know what you&#8217;re thinking &#8212; if I just provide a text field for the user to paste in a URL how will I know what service to query? There&#8217;s two obvious ways you can handle that. One would be to provide a drop down menu that allows users to specify the source of the link. The other would be the just parse the link with some <a href="/2010/02/Regular_Expressions_Tutorial" class="external text" title="/2010/02/Regular_Expressions_Tutorial" rel="nofollow">Regular Expressions</a> <a href="/2010/02/Use_Regex_in_Perl" class="external text" title="/2010/02/Use_Regex_in_Perl" rel="nofollow">magic</a> and handle it transparently.



</p><p>If you have other ideas, be sure to add them.

</p>

<a name="Getting_more_complex"></a><h2> <span class="mw-headline">Getting more complex</span></h2>

<p>That&#8217;s all well and good, but what about more complex examples like video? This is actually where OEmbed shines &#8212; no more filling in some complex embedding template that&#8217;s liable to break whenever something changes on the source site.

</p><p>This time we&#8217;ll use Viddler as an example. Let&#8217;s say the visitor to our sharing site wants to embed <a href="http://www.viddler.com/explore/RickRoll/videos/2/" class="external text" title="http://www.viddler.com/explore/RickRoll/videos/2/" rel="nofollow">this video</a>. They copy the URL and paste it in our form&#8217;s text field. Then we query Viddler&#8217;s OEmbed URL. But this time, we&#8217;ll add a parameter to make sure the embedded video is 400 pixels wide.

</p><p>The query code would look like this:

</p>

<pre class="brush: js">http://lab.viddler.com/services/oembed/?url=http%3A%2F%2Fwww.viddler.com%2Fexplore%2FRickRoll%2Fvideos%2F2%2F&amp;width=400&amp;format=xml

</pre>

<p>Viddler will then return this XML response (or if you change the <code>format</code> parameter to JSON, you could get a JSON response):



</p><p><br />

</p>

<pre class="brush: js">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;OEmbed&gt;

	&lt;version&gt;1.0&lt;/version&gt;

	&lt;type&gt;video&lt;/type&gt;

	&lt;width&gt;400&lt;/width&gt;



	&lt;height&gt;342&lt;/height&gt;

	&lt;title&gt;Rick Roll Muppets Version&lt;/title&gt;

	&lt;url&gt;http://www.viddler.com/explore/RickRoll/videos/2/&lt;/url&gt;

	&lt;author_name&gt;RickRoll&lt;/author_name&gt;



	&lt;author_url&gt;http://www.viddler.com/explore/RickRoll/&lt;/author_url&gt;

	&lt;provider&gt;Viddler&lt;/provider&gt;

	&lt;provider_url&gt;http://www.viddler.com/&lt;/provider_url&gt;

	&lt;html&gt;&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="342" id="viddlerplayer-4310bfba"&gt;&lt;param name="movie" value="http://www.viddler.com/player/4310bfba/" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;embed src="http://www.viddler.com/player/4310bfba/" width="400" height="342" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddlerplayer-4310bfba" &gt;&lt;/embed&gt;&lt;/object&gt;&lt;/html&gt;



&lt;/OEmbed&gt;

</pre>

<p>As you can see, the last element of the response, the <code>html</code> node, gives us the embed code and keeps the video constrained to the dimensions we specified. It doesn&#8217;t get much easier than that.

</p><p>Viddler has even put together a cool little sample app that <a href="http://lab.viddler.com/services/oembed/form.php" class="external text" title="http://lab.viddler.com/services/oembed/form.php" rel="nofollow">shows OEmbed in action</a>.

</p>

<a name="Security_Note"></a><h3> <span class="mw-headline">Security Note</span></h3>

<p>When you&#8217;re creating a site that&#8217;s going to display HTML (as with video embeds), there&#8217;s always the potential for cross-site scripting (XSS) attacks from the site providing the code. At the moment, all the sites offering OEmbed are reputable, but that may not always be the case. To avoid opening your site up to XSS attacks, the OEmbed authors recommend displaying the HTML in an iframe, hosted from another domain. This ensures that the HTML cannot access cookies from the consumer domain.

</p>

<a name="Sky.27s_the_Limit"></a><h2> <span class="mw-headline">Sky&#8217;s the Limit</span></h2>



<p>OEmbed isn&#8217;t just for developers either. If you wrapped OEmbed as a WordPress or Movable Type Plug-in, even posting content on your own site would be considerably easier. At the moment no one has released any plug-ins, but the specification is still young.

</p><p>If happen to be working with the Django web framework, there&#8217;s already a nice set of <a href="http://code.google.com/p/django-oembed/" class="external text" title="http://code.google.com/p/django-oembed/" rel="nofollow">OEmbed template tags</a> up on Google code. The project allows you to do things like this in your Django templates:

</p>

<pre class="brush: js">{% OEmbed&nbsp;%}

http://www.flickr.com/photos/luxagraf/

{% endOEmbed&nbsp;%}

</pre>

<p><br />

</p>

<a name="Why_We_Love_OEmbed"></a><h2> <span class="mw-headline"> Why We Love OEmbed </span></h2>



<p>There&#8217;s a bunch of ever-changing social web specs out there promising all sort of things, from easier logins though OAuth and OpenID to Google and Facebook&#8217;s widget platforms. But where many of the promises of those specs remain unfulfilled, OEmbed is here today and it just works.

</p><p>Obviously, it&#8217;s missing some key provider sites like YouTube or Picasa, but hopefully it won&#8217;t be long before OEmbed becomes a standard part of every successful web API.

</p><p>Check out the list of current implementations at the <a href="http://oembed.com/" class="external text" title="http://oembed.com/" rel="nofollow">OEmbed website</a>. Also worth a look is Deepak Sarda&#8217;s <a href="http://oohembed.com/" class="external text" title="http://oohembed.com/" rel="nofollow">OohEmbed</a>. The new service will spit out the embed schemes for various sites that haven&#8217;t had a chance to implement OEmbed themselves. For example, here&#8217;s the <a href="http://oohembed.com/oohembed/?url=http%3A//www.youtube.com/watch%3Fv%3Dvk1HvP7NO5w" class="external text" title="http://oohembed.com/oohembed/?url=http%3A//www.youtube.com/watch%3Fv%3Dvk1HvP7NO5w" rel="nofollow">JSON response for a YouTube video</a>.

</p><div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2010/02/get_started_with_oembed/feed/</wfw:commentRss>
        <slash:comments>14</slash:comments>

        
    </item>
    </channel>
</rss>