Accessing YouTube via its C# API
Here are two examples on how to use Google’s C# API to access YouTube (using O2 Platform‘s Quick Develoment Gui).
Example 1: List the latest feeds
panel.clear();
var googleDevKey = "AI39si4VZRef7hm9N-RBZ5u-5x5N2lIgyEvv45dGgDxCJjltduhlnF9tTmfWV55tFMUWbnThHybbipiXiEufJueJPpF65lkyjg ";
var settings = new YouTubeRequestSettings("API_YouTube",googleDevKey);
var youTubeRequest = new YouTubeRequest(settings);
Feed<Video> feed = youTubeRequest.GetStandardFeed(YouTubeQuery.MostPopular);
panel.add_TableList().show(feed.Entries);
return "done";
//using Google.YouTube
//using Google.GData.Client
//using Google.GData.YouTube
//O2Ref:Google.GData.Client.dll
//O2Ref:Google.GData.YouTube.dll
//O2Ref:Google.GData.Extensions.dll
Example 2: Upload Video
var account = @"C:\O2\_USERDATA\Accounts.xml".credential("YouTube");panel.clear();
var googleDevKey = "AI39si4VZRef7hm9N-RBZ5u-5x5N2lIgyEvv45dGgDxCJjltduhlnF9tTmfWV55tFMUWbnThHybbipiXiEufJueJPpF65lkyjg ";
var settings = new YouTubeRequestSettings("API_YouTube",googleDevKey, account.UserName, account.Password);
var videoToUpload= @"C:\O2\DemoData\O2Videos\_Test_Video_1.avi";
var youTubeRequest = new YouTubeRequest(settings);
var video = new Video();
video.Title = "First Test 1";
video.Title = "This is the first YouTube API test";
video.Keywords = "O2 Test";
MediaCategory category = new MediaCategory("Technology");
category.Attributes["scheme"] = YouTubeService.DefaultCategory;
video.Tags.Add(category);
video.MediaSource = new MediaFileSource(videoToUpload, "video/avi");
return youTubeRequest.Upload(video);
return "done";
//O2File:SecretData_ExtensionMethods.cs
//using Google.YouTube
//using Google.GData.Client
//using Google.GData.YouTube
//using Google.GData.Extensions.MediaRss
//O2Ref:Google.GData.Client.dll
//O2Ref:Google.GData.YouTube.dll
//O2Ref:Google.GData.Extensions.dll



Note, the MediaCategory has to be set to
MediaCategory category = new MediaCategory(“Tech”);
the example above was working before, but YouTube must have made some changes
[...] on the Accessing YouTube via its C# API script , here are two more uses of the YouTube C# [...]