使用文档API不可靠地获取谷歌文档

时间:2013-04-21 07:23:24

标签: google-app-engine google-docs-api

我在谷歌应用引擎上有一个应用程序,在一段代码中,我使用文档API读取了一个谷歌文档。代码如下:

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
            oauthParameters.setOAuthConsumerKey(Constants.CONSUMER_KEY);
            oauthParameters.setOAuthConsumerSecret(Constants.CONSUMER_SECRET);
            oauthParameters.setOAuthToken(Constants.ACCESS_TOKEN);
            oauthParameters.setOAuthTokenSecret(Constants.ACCESS_TOKEN_SECRET);
            DocsService client = new DocsService("sakshum-YourAppName-v1");
            client.setOAuthCredentials(oauthParameters,
                    new OAuthHmacSha1Signer());
            URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/");
            DocumentQuery dquery = new DocumentQuery(feedUrl);
            dquery.setTitleQuery(title);
            dquery.setTitleExact(true);
            dquery.setMaxResults(10);
            DocumentListFeed resultFeed = client.getFeed(dquery,
                    DocumentListFeed.class);

并且失败,例外:

vik.sakshum.sakshumweb.server.common.CommonServiceCode getGoogleDoc: Exception is :Unable to complete the HTTP request

这种情况并非总是发生,但有时会发生。那么,处理这种失败情况的正确方法应该是什么?这是GAE apis非常不可靠的问题吗?这是一个代码问题,我可以修复以更好的方式或其他方式处理它?<​​/ p>

0 个答案:

没有答案
相关问题