我需要知道谷歌帐户的rss列表。我通过以下api得到了sid和auth,并且它成功了。
// login and get sid & auth
NSURL* loginURL = [NSURL URLWithString:@"https://www.google.com/accounts/ClientLogin"];
ASIFormDataRequest* loginRequest = [ASIFormDataRequest requestWithURL:loginURL];
loginRequest.useCookiePersistence = NO;
[loginRequest addRequestHeader:@"User-Agent" value:@"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4"];
[loginRequest setPostValue:@"reader" forKey:@"service"];
[loginRequest setPostValue:@"scroll" forKey:@"source"];
[loginRequest setPostValue:@"http://www.google.com/" forKey:@"continue"];
[loginRequest setPostValue:self.login forKey:@"Email"];
[loginRequest setPostValue:self.password forKey:@"Passwd"];
[loginRequest startSynchronous];
但尝试获取令牌时失败了。
NSString *lUrlString = @"http://www.google.com/reader/api/0/subscription/list?output=json&client=scroll";
_rssRequest = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:lUrlString]];
NSString *authParam = [NSString stringWithFormat:@"GoogleLogin auth=%@", self.auth];
[_rssRequest addRequestHeader:@"Authorization" value:authParam];
[_rssRequest addRequestHeader:@"Cookie" value:[NSString stringWithFormat:@"SID=%@", [self sid]]];
[_rssRequest setHeadersReceivedBlock:^(NSDictionary *responseHeaders) {
NSLog(@"%@", responseHeaders);
}];
[_rssRequest setRequestMethod:@"GET"];
[_rssRequest setValidatesSecureCertificate:NO];
[_rssRequest setDelegate:self];
[_rssRequest setDidFailSelector:@selector(rssLoadFailed:)];
[_rssRequest setDidFinishSelector:@selector(rssLoadFinish:)];
[_rssRequest startAsynchronous];
- (void)rssLoadFailed:(ASIHTTPRequest *)req
{
NSError *error = [req error];
NSLog(@"%@", [error description]);
NSLog(@"Get token Failed: %d %@", [req responseStatusCode], [req responseStatusMessage]);
}
- (void)rssLoadFinish:(ASIHTTPRequest *)req
{
NSLog(@"%@", req);
NSData * returnData = [req responseData];
NSString* response;
response = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
NSLog(@"%@", response);
}
当我试图获取rss列表时,我收到401错误。 有人知道使用谷歌阅读器api重读阅读清单有什么问题吗? 在此先感谢您的帮助!