如何使用API​​通过代理服务器上传到YouTube

ban*_*ter 2 .net c# youtube-api

我正在构建一个应用程序,允许用户将视频上传到您管道上的特定帐户.

我已按照http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html上的示例进行了直接上传,但我现在正在request.Upload(newVideo)调用时需要进行407代理身份验证.

我使用代理(http://code.google.com/p/google-gdata/wiki/WebProxySetup)找到了Google Calendar Service的示例,但似乎无法解决如何为YouTube重构它.

有任何想法吗?

Ran*_*pho 5

听起来您的代理需要凭据.证书必须以代码提供; 我正在搜索Google API的源代码来查找它,因为它们有自己的自定义请求对象.

与此同时,您可以通过简单地使用默认代理来使其工作.修改app.config或web.config以将其插入正确的位置:

<configuration>
 <system.net>
  <defaultProxy>
   <proxy usesystemdefault="false"/>
  </defaultProxy>
 </system.net>
</configuration>
Run Code Online (Sandbox Code Playgroud)

编辑:

好的,在做了一些挖掘之后,我认为你会重构你为特定请求链接的指令.假设您已经创建了一个YouTubeRequest,如下所示:

YouTubeRequest request = new YouTubeRequest(settings);
Run Code Online (Sandbox Code Playgroud)

以下是您链接中的重构说明:

YouTubeRequest request = new YouTubeRequest(settings);
GDataRequestFactory f = (GDataRequestFactory) request.Service.RequestFactory;
IWebProxy iProxy = WebRequest.DefaultWebProxy;
WebProxy myProxy = new WebProxy(iProxy.GetProxy(query.Uri));
// potentially, setup credentials on the proxy here
myProxy.Credentials = CredentialsCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
f.Proxy = myProxy;
Run Code Online (Sandbox Code Playgroud)

以下是我的消息来源:

http://google-gdata.googlecode.com/svn/docs/folder56/T_Google_YouTube_YouTubeRequest.htm

http://google-gdata.googlecode.com/svn/docs/folder53/P_Google_GData_Client_FeedRequest_1_Service.htm

http://google-gdata.googlecode.com/svn/docs/folder19/P_Google_GData_Client_Service_RequestFactory.htm