【发布时间】:2026-01-03 08:40:02
【问题描述】:
是否有人能够帮助了解如何让这个 C# 示例通过我的代理服务器工作。我注意到http://code.google.com/apis/gdata/articles/proxy_setup.html#dotnet 有一个代码示例,它提供了一些方向,但是我在如何将其应用于 DocListExporter 示例方面遇到了麻烦。换句话说:
如何在此处应用代码概念(使用代理):
CalendarService service = new CalendarService("CalendarSampleApp");
GDataRequestFactory requestFactory = (GDataRequestFactory)
service.RequestFactory;
WebProxy myProxy = new WebProxy("http://my.proxy.example.com:3128/",true);
// potentially, setup credentials on the proxy here
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
requestFactory.Proxy = myProxy;
示例中的以下代码:
GoogleClientLogin loginDialog = new GoogleClientLogin(new DocumentsService("GoogleDocumentsSample"), "youremailh...@gmail.com");
if (loginDialog.ShowDialog() == DialogResult.OK)
{
RequestSettings settings = new RequestSettings("GoogleDocumentsSample", loginDialog.Credentials);
settings.AutoPaging = true;
settings.PageSize = 100;
if (settings != null)
{
this.request = new DocumentsRequest(settings);
this.Text = "Successfully logged in";
Feed<Document> feed = this.request.GetEverything();
// this takes care of paging the results in
foreach (Document entry in feed.Entries)
{
all.Add(entry);
}
另外,如果您知道如何包含实际代理用户名/密码的语法,那也会很酷。
谢谢
【问题讨论】: