我正在尝试在iPhone APP中实现google reader,到目前为止我已经成功收到了sid and auth。当我尝试使用以下命令调用 Endpoints API 时,问题就出现了GET..这是代码:
ASIHTTPRequest *request = [self requestForAPIEndpoint:@"https://www.google.com/reader/api/0/subscription/list?output=json"];
[request setDelegate:self];
[request startAsynchronous];
- (ASIHTTPRequest *) requestForAPIEndpoint: (NSString *) apiEndpoint
{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString: apiEndpoint]];
[request addRequestHeader: @"User-Agent" value: @"YourClient"];
[request addRequestHeader: @"Cookie" value: signature];
NSLog(@"Sig = %@",signature);
[request addRequestHeader: @"Authorization" value: autho];
return request.
}
作者和签名设置正确。然而每次我接到回电时 -(void)requestFailed:(ASIHTTPRequest *)请求方法。我做错了什么?我是否需要注册一些访问 API 的位置并将用户代理设置为该名称?
我修改了请求API端点方法如下,我也有同样的问题。
- (ASIHTTPRequest *) requestForAPIEndpoint: (NSString *) apiEndpoint
{
NSDictionary *properties = [[[NSMutableDictionary alloc] init] autorelease];
[properties setValue:signature forKey:NSHTTPCookieValue];
[properties setValue:@"SID" forKey:NSHTTPCookieName];
[properties setValue:@".google.com" forKey:NSHTTPCookieDomain];
[properties setValue:@"1600000000" forKey:NSHTTPCookieExpires];
[properties setValue:@"/" forKey:NSHTTPCookiePath];
NSHTTPCookie *cookie = [[[NSHTTPCookie alloc] initWithProperties:properties] autorelease];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString: apiEndpoint]];
[request setUseCookiePersistence:NO];
[request setRequestCookies:[NSMutableArray arrayWithObject:cookie]];
[request addRequestHeader: @"User-Agent" value: @"YourClient"];
[request addRequestHeader: @"Authorization" value: autho];
return request;
}
如果您使用 ClientLogin(通过Authorization
标题)。看http://code.google.com/p/google-reader-api/wiki/Authentication http://code.google.com/p/google-reader-api/wiki/Authentication了解支持的身份验证方案。
此外,Authorization
标头的格式应为GoogleLogin auth=<auth token>
where <auth token>
is the Auth
来自 ClientLogin 响应的值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)