我使用java和gdata API来管理我的Calendar数据。但它只有在我可以直接访问互联网时才有效。在我的情况下,我必须使用代理。有没有办法通过代理管理我的Google日历数据?
我是这样试过的:
System.setProperty("http.proxyHost", "myproxy.mydomain.com");
System.setProperty("http.proxyPort", "3128");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/....");
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
String encoded = new String(Base64.encodeBase64(new String("proxy_user:proxy_password").getBytes()));
String base64encodedCredentials = "Basic " + encoded;
myService.getRequestFactory().setPrivateHeader("Proxy-Authorization", base64encodedCredentials);
//!!! Exception in this line
myService.setUserCredentials("my_google_accaunt@gmail.com", "my_google_password");
例外:
Exception in thread "main" com.google.gdata.util.AuthenticationException: Error connecting with login URI
at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:549)
at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:397)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:364)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:319)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:303)
at calendartest.CalendarTest.getCalendarEventsWithProxy(CalendarTest.java:145)
at calendartest.CalendarTest.main(CalendarTest.java:195)
Caused by: java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
没有代理,一切正常。
答案 0 :(得分:1)
您没有说出您正在使用的语言,但Java和.Net#的说明位于:
https://developers.google.com/gdata/articles/proxy_setup
有关Python的说明,请访问:
http://code.google.com/p/gdatacopier/wiki/ProxySupport(这些应适用于使用gdata-python-client的任何应用)