【发布时间】:2015-06-26 17:35:16
【问题描述】:
我正在使用 gdata 获取应用用户的 gmail 联系人照片,代码如下。但有时 fetch 工作,有时它不工作,并给我以下错误:(我怀疑给谷歌服务器提供了太多令牌?虽然我还不太熟悉这个概念。但我确实需要获取所有用户`s联系人照片,有没有办法解决它??)
提前谢谢你,
imageFetcher:GTMHTTPFetcher 0x145ea3300 (https://www.google.com/m8/feeds/photos/media/XXXXX%40gmail.com/XXXXX) failedWithError:Error Domain=com.google.HTTPStatus Code=503 “操作无法完成。(com.google.HTTPStatus 错误 503。)”
if ([[[contact photoLink] ETag] length] ) {
// imageData = [NSData dataWithContentsOfURL:photoURL];
// requestForURL:ETag:httpMethod: sets the user agent header of the
// request and, when using ClientLogin, adds the authorization header
// get an NSURLRequest object with an auth token
self.flyingtoken ++;
NSURL *imageURL = [[contact photoLink] URL];
GDataServiceGoogleContact *service = [self contactService];
// requestForURL:ETag:httpMethod: sets the user agent header of the
// request and, when using ClientLogin, adds the authorization header
NSMutableURLRequest *request = [service requestForURL:imageURL
ETag:nil
httpMethod:nil];
[request setValue:@"image/*" forHTTPHeaderField:@"Accept"];
GTMHTTPFetcher *fetcher = [GTMHTTPFetcher fetcherWithRequest:request];
[fetcher setAuthorizer:[service authorizer]];
[fetcher beginFetchWithDelegate:self
didFinishSelector:@selector(imageFetcher:finishedWithData:error:)];
}
【问题讨论】:
-
谷歌服务器一般返回503错误,表示您的配额已超出。尝试实现指数回退developers.google.com/api-client-library/java/…
-
谢谢。我同意你的看法,这表明超出了配额。我没有向谷歌资源服务器发出太多未完成的请求来解决它。
标签: ios objective-c gdata gmail-api