KnowlegeZone.com, Share knowledge Gain knowledge
New Articles:
     

Home > ASP : YouTube REST API Tutorial

Article By: Saqib   Date: 4/30/2010

YouTube REST API Tutorial

YouTube REST API Tutorial 

What does this Code/API do?
it retrieves videos from Youtube. you specify a keyword and it will return those videos for you.
 
Do I need an account with youtube to implement this?
No, it’s a copy and paste project. you will be up within 5 minutes.
 
Do I need Programming experience to implement this?
Nope, just the basics. Simply upload the dll, copy and paste the code below. That’s it.
 
 
 
You can have Youtube API working within 5 minutes by using provided DLL. This DLL uses REST Api Calls to retrieve data. you don’t need any account with youtube for this API to implement.
 
Tutorial.
 
 
Step 1:
first you need to download the DLL. Download DLL
 
Step 2:
Upload DLL to Bin folder of your website’s root directory.
 
Step3:
Create a Literal Control on your newly created aspx page.
 
<asp:Literal runat=server ID="Dramas"></asp:Literal>
 
Step3:
 Open up the Code Behind File and paste following into the Page_Load event. don’t forget to import the namespace at top of the page.
 
Imports YouTubeApi
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 
        Dim data As New YouTubeData
 
        data.keyword = "UFC Videos"
       data.startIndex = 1
 
        Dim b As Collection(Of YouTubeItems)
        b = data.createRequest
 
 
        str = "<table cellpadding=2>"
 
        For Each Item As YouTubeItems In b
 
 
            str += "<tr><td>"
            str += "<a href='Asian_Drama.aspx?vid=" & Item.VideoID & "&Serial=" & Me.SerialName & "&keyword=" & Me.SearchKeyword & "'><img src='http://i2.ytimg.com/vi/" & Item.VideoID & "/default.jpg' /></a></td>"
            str += "<td valign=top><a href='Asian_Drama.aspx?vid=" & Item.VideoID & "&Serial=" & Me.SerialName & "&keyword=" & Me.SearchKeyword & "'><b>" & Item.VideoTitle & "</b></a><br/><i>" & Item.published & "</i></td>"
            str += "</tr>"
 
        Next
 
        str += "</table>"
 
               
 
                Dramas.Text = str ' Dramas is the name of Literal Control on your aspx page
 
    Ens sub
 
 
That’s it. Change the keyword value to whatever you want to return different results. To do the paging, change the startIndex Value
to whatever page you want to land on.
 
 
API supports following Input/Properties
 
Keyword: Your Search keyword
startIndex: for paging, 1 = first page, 2 = second page
 
 
API return's following properties.
 
 
VideoID: Unique ID of the video, use it to create the Video Link, and Image Thumbnails.
VideoTitle: Title of the Returned Video(s)
published: Date & Time when video was uploaded.
 
 
if you have any questions, please feel free to post below.
 
Thanks


Share |


Comments.
Comment/Solution Posted By: Ranjan Kumar    Date: 5/22/2010 10:23:00 AM
How can I retrieve recently posted Comments/previous comments on any video in you tube in our application using C# ASP.Net.Please provide detail coding with DLL

Thanks in Advance
Ranjan.

Comment/Solution Posted By: Skhan    Date: 5/22/2010 10:42:00 AM
Unfortunately API does not return any comments, however if you want to do it yourself using REST API then here is the end point url.

http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments

Simply Replace VIDEO_ID with the ID returned from API, and show comments on page.

if you really want me to modify the DLL then i can probably do this as soon as I get some time.

Thanks

Comment/Solution Posted By: Hitesh Pardeshi    Date: 7/13/2010 10:52:00 AM
Hi,

Nice work.

I want to read all comment from specific video that I Passed by url and also that I want to vote up/down from my application.

Is it possible ? If yes, then How ?
And Also Is it possible in Desktop application ?

Pleae reply.

Thanks,

Comment/Solution Posted By: Ugo    Date: 11/17/2010 6:15:00 AM
Ohhh the download of DLL no work!!!
Where i can download it?

Comment/Solution Posted By: skhan    Date: 11/18/2010 1:56:00 AM
Link has been patched. try again.

Comment/Solution Posted By: vertigo262    Date: 1/25/2011 8:32:00 AM
get an error on

Dim b As Collection(Of YouTubeItems)

Microsoft.visualbasic.collection has no type of parameters so cannot have type arguments

I have this namespace

Imports YouTubeApi

Comment/Solution Posted By: Skhan    Date: 1/25/2011 4:51:00 PM
did you place the DLL in Bin Directory(root) of website?

also make sure you using Framework version 2.0.

Comment/Solution Posted By: Bobby    Date: 8/29/2011 12:18:00 PM
Changed to Framework Version 2.0 , no effect .
Still getting this error.

Microsoft.visualbasic.collection has no type of parameters so cannot have type arguments

If I import
Imports System.Collections.ObjectModel
Then I get series of errors

Error 1 SerialName is not a member of
What to do

Comment/Solution Posted By: khan    Date: 8/29/2011 12:43:00 PM
just importing...

Imports System.Collections


Pages :
Post Comment or Solution   OR   Sign in using Google/Aol/Yahoo/Msn/OpenID
Your Name:  
Your Email:  
Comments:
 
Please Verify:
(Type Answer)