Hi,Every one!
I try to use c# api to upload video to youtube,but always failed.
the code is showed below.Please help me find out the error.thank you!
public class YoutubeService
{
private const string clientID = "********************";
private const string developerKey =
"************************";
private YouTubeService m_service;
public void CreateService(string appName)
{
m_service = new YouTubeService(appName, clientID,
developerKey);
}
public void setUserCredentials(string username, string
password)
{
m_service.setUserCredentials(username, password);
}
public void UploadFile()
{
YouTubeEntry newEntry = new YouTubeEntry();
newEntry.MediaSource = new MediaFileSource(@"F:\MyDocument
\My Pictures\20080211\20080211018.mp4", "video/mp4");
newEntry.Media = new MediaGroup();
newEntry.Media.Description = new MediaDescription("Test
uploading video to youtube");
newEntry.Media.Title = new MediaTitle("Sample upload");
newEntry.Media.Keywords = new MediaKeywords("math");
MediaCategory category = new MediaCategory("Nonprofit");
category.Attributes["scheme"] =
YouTubeService.DefaultCategory;
newEntry.Media.Categories.Add(category);
try
{
Console.WriteLine("Upload......");
YouTubeEntry entry =
m_service.Upload("[EMAIL PROTECTED]",newEntry);
}
catch (Google.GData.Client.GDataRequestException e)
{
Console.WriteLine("Exception happen!" + e.ToString());
}
catch (Google.GData.Client.InvalidCredentialsException e)
{
Console.WriteLine("Invalid credentials");
}
catch
{
Console.WriteLine("Failed to upload!");
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Data Protocol" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---