This is a mirror of official site: http://jasper-net.blogspot.com/

How to use Google Data API in ASP.NET MVC. Part 2

| Sunday, May 30, 2010
Previously on this series, I had talked about  How to use Google Data API in ASP.NET MVC to interact with Google Analytics. In this second part I'm going to show you how to store and retrieve videos on/from YouTube using Google Data API and YouTube API.

YouTube is the largest and most popular video sharing website and since Google has acquired it and integrated its API into GData it's been an ultimate choice for developers to choose it as a safe and powerful backend for their videos.

I should mention that there are two types of YouTube APIs for developers:

The Data API which lets you incorporate YouTube functionality into your own application or website. You can perform searches, upload videos, create playlists, and more.
The Player APIs which give you control over YouTube video playback on your website. Configure basic settings, drive the player interface, or even build your own player controls.
One may add the third Custom Player to the list above but indeed it's not an API.

In our tutorial we will go through the first item: Data API; the second is left for JS and AS developers and maybe Pedram would write about it!

Well, let's go!

I'll divide my blog post main content into two seperate topics: Storing Videos and Retrieving Video.

First of all your have to prepare required tools to interact with YouTube Data API. Here's what you would do:

Sign up for a developer key. You will also need your Google account username and password.

Download YouTube SDK.

After installing YouTube SDK, reference the following assemblies in your project:

public static YouTubeRequest GetRequest()
{

   var request = HttpContext.Current.Session["YTRequest"] as YouTubeRequest;

   if (request == null)

   {

       var settings = new YouTubeRequestSettings("SampleWebApp", "NA",
                             ConfigurationManager.AppSettings["YouTubeAPIDeveloperKey"],
                             ConfigurationManager.AppSettings["YouTubeUsername"],
                             ConfigurationManager.AppSettings["YouTubePassword"]);

       request = new YouTubeRequest(settings);

       HttpContext.Current.Session["YTRequest"] = request;

   }

   return request;

}

Read more: Mahdi Taghizadeh

Posted via email from jasper22's posterous

0 comments: