C# 使用ASP.NET C上传到YouTube-避免;谷歌登录“;屏幕
我正在创建一个ASP.NET C#应用程序,将视频上传到YouTube频道。 *我已经(尽我所能)通读了 使用提供的示例代码,我成功地实现了两个将视频上传到YouTube频道的示例 例如,使用直接法(仅随附重要代码): UploadVideo.aspx页面是实际的上传表单,它可以正常工作,所以我不担心这一点 替代方法不是推荐的方法,因为它本质上是同步的,但它确实避免了登录屏幕,因为它允许我们传递凭据以进行身份验证(它作为web应用程序工作)…下面再次附上主要代码C# 使用ASP.NET C上传到YouTube-避免;谷歌登录“;屏幕,c#,asp.net,video,upload,youtube-api,C#,Asp.net,Video,Upload,Youtube Api,我正在创建一个ASP.NET C#应用程序,将视频上传到YouTube频道。 *我已经(尽我所能)通读了 使用提供的示例代码,我成功地实现了两个将视频上传到YouTube频道的示例 例如,使用直接法(仅随附重要代码): UploadVideo.aspx页面是实际的上传表单,它可以正常工作,所以我不担心这一点 替代方法不是推荐的方法,因为它本质上是同步的,但它确实避免了登录屏幕,因为它允许我们传递凭据以进行身份验证(它作为web应用程序工作)…下面再次附上主要代码 <% GAuth
<%
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(ServiceNames.YouTube, "TesterApp");
// Response.Write("serviceNames.youtube=" + ServiceNames.YouTube + "<br />");
YouTubeRequestSettings s = new YouTubeRequestSettings(authFactory.ApplicationName, **your API KEY**,**Your email account as a username**,**your password**);
YouTubeRequest request = new YouTubeRequest(s);
Video newVideo = new Video();
newVideo.Title = "test at 4:40";
newVideo.Tags.Add(new MediaCategory("Games", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "cars, funny";
newVideo.Description = "My description";
newVideo.YouTubeEntry.Private = false;
// newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));
// newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
// alternatively, you could just specify a descriptive string
newVideo.YouTubeEntry.setYouTubeExtension("location", "Somewhere,Someplace");
newVideo.YouTubeEntry.MediaSource = new MediaFileSource("C:\\IMG_1672.MOV",
"video/quicktime");
Video createdVideo = request.Upload(newVideo);
Response.Write("This will print out once the file is uploaded...indicates that the code is <i>synchronous</i>. The cursor spins around until done. go get a coffee then check the YouTube Channel");
%>
因此,基本上我要问的问题是——有没有一种方法可以将视频上传到ASP.NET中的YouTube频道C#code a)用于web应用程序b)我可以通过代码将凭据传递到C)绕过上面看到的Google身份验证屏幕d)而不使用OAuth、openID和证书等
该应用程序仅用于短期活动(仅11月),我很乐意使用已弃用的authSubUtil和开发密钥,不必担心oAuth 2.x或open ID(因为authSubUtil将在2015年弃用)
感谢您的帮助
谢谢
Edward您最好使用ClientLogin身份验证,您可以在其中存储用户帐户的用户名和密码,然后使用DirectUpload 直接上传: 客户端登录:
注意:客户端登录已被弃用,他们希望您使用OAuth,但是如果您快速使用,您应该不会有问题 Apostol先生-我编辑了你的文档以显示图像。如果这是错误的图像,请让我知道。
// create an instance ot the YouTubeService class. passing the application name and my DEV KEY
YouTubeService service = new YouTubeService(authFactory.ApplicationName, **API_KEY**);
// retrieve the current session token as a string if any
authFactory.Token = HttpContext.Current.Session["token"] as string;
// incorporate the information into our service
service.RequestFactory = authFactory;
try
{
// a YouTubeEntry object is single entity within a videoFeed object. It generally contains info
// about the video. when uploading, we will assign the values that we received to the feed.
YouTubeEntry entry = new YouTubeEntry();
// aggregate all the initial descriptor information
entry.Media = new Google.GData.YouTube.MediaGroup();
entry.Media.Description = new MediaDescription(this.Description.Text);
entry.Media.Title = new MediaTitle(this.Title.Text);
entry.Media.Keywords = new MediaKeywords(this.Keyword.Text);
// process entry.Media.Categories to assign the category
MediaCategory category = new MediaCategory(this.Category.SelectedValue);
category.Attributes["scheme"] = YouTubeService.DefaultCategory;
entry.Media.Categories.Add(category);
// prepare the token used for uploading
FormUploadToken token = service.FormUpload(entry);
HttpContext.Current.Session["form_upload_url"] = token.Url;
HttpContext.Current.Session["form_upload_token"] = token.Token;
// construct the URL
string page = "http://" + Request.ServerVariables["SERVER_NAME"];
if (Request.ServerVariables["SERVER_PORT"] != "80")
{
page += ":" + Request.ServerVariables["SERVER_PORT"];
}
page += Request.ServerVariables["URL"];
HttpContext.Current.Session["form_upload_redirect"] = page;
Response.Redirect("UploadVideo.aspx");
<%
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(ServiceNames.YouTube, "TesterApp");
// Response.Write("serviceNames.youtube=" + ServiceNames.YouTube + "<br />");
YouTubeRequestSettings s = new YouTubeRequestSettings(authFactory.ApplicationName, **your API KEY**,**Your email account as a username**,**your password**);
YouTubeRequest request = new YouTubeRequest(s);
Video newVideo = new Video();
newVideo.Title = "test at 4:40";
newVideo.Tags.Add(new MediaCategory("Games", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "cars, funny";
newVideo.Description = "My description";
newVideo.YouTubeEntry.Private = false;
// newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));
// newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
// alternatively, you could just specify a descriptive string
newVideo.YouTubeEntry.setYouTubeExtension("location", "Somewhere,Someplace");
newVideo.YouTubeEntry.MediaSource = new MediaFileSource("C:\\IMG_1672.MOV",
"video/quicktime");
Video createdVideo = request.Upload(newVideo);
Response.Write("This will print out once the file is uploaded...indicates that the code is <i>synchronous</i>. The cursor spins around until done. go get a coffee then check the YouTube Channel");
%>