Using oEmbed with Known Providers

Using oEmbed is quick and easy. In the typical implementation, your end user would enter a URL as plain text, among other text. For example, we do this all of the time in online text editors, such as the FCKeditor or RadEditor. For example, they'd add a YouTube URL like so:

http://www.youtube.com/watch?v=hQTrUpmIgH0

Entering the URL alone would usually not do anything all on it's own. However, when you use the oEmbed API, the URL will "automagically" be turned into the video found at the preceding URL. The magic part only happens for the end-user, not you. :P



You would parse the input from the end-user to pull the URL, and then run code similar to this:

Dim objYouTube As New WillStrohl.API.oEmbed.Providers.YouTube
Dim strVideo As String
strVideo = objYouTube.GetVideo("http://www.youtube.com/watch?v=hQTrUpmIgH0", 500, 350)
Response.Write(strVideo)

Or, using the open REST call of the API, you would:

Dim ctlEmbed As New WillStrohl.API.oEmbed.Wrapper
Dim objRequest As New WillStrohl.API.oEmbed.RequestInfo
objRequest.URL = "http://www.youtube.com/watch?v=hQTrUpmIgH0"
objRequest.MaxWidth = 500
objRequest.MaxHeight = 350

Dim strVideo As String
strVideo = ctlEmbed.GetVideoContent("http://www.youtube.com/oembed", objRequest)
Response.Write(strVideo)

Either way, the code that gets returned, and rendered is the same:

<object width="425" height="344">
    <param name="movie" value="http://www.youtube.com/v/u7zlDicbfhI&fs=1"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/u7zlDicbfhI&fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>

Last edited Sep 16, 2011 at 1:00 AM by hismightiness, version 4

Comments

No comments yet.