|
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:
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
|