访问谷歌阅读器的端点 API 时出错 [英] Error in accessing google reader's Endpoints API

查看:24
本文介绍了访问谷歌阅读器的端点 API 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 iPhone APP 中实现谷歌阅读器,到目前为止我已经成功收到了 sidauth.当我尝试使用 GET 调用 Endpoints API 时出现问题.代码如下:

I am trying to implement google reader in iPhone APP and so far I have successfully received the sid and auth. The problem arises when I try to call the Endpoints API with GET.. Here's the code:

 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 *)request 方法.我做错了什么??我是否需要注册一些访问 API 的位置并将用户代理设置为该名称?

The autho and signature are correctly set. However every-time I get callback in - (void)requestFailed:(ASIHTTPRequest *)request method. What is that I am doing wrong?? Do I need to register some where to access the API and set the user-agent to that name??

我修改了 requestForAPIEndpoint 方法如下,然后我也遇到了同样的问题.

I modified the requestForAPIEndpoint method as follows then also I have the same problem.

- (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 标头),则不需要提供 SID cookie.请参阅 http://code.google.com/p/google-reader-api/wiki/Authentication 用于支持的身份验证方案.

You don't need to provide the SID cookie if you are using ClientLogin (via the Authorization header). See http://code.google.com/p/google-reader-api/wiki/Authentication for the supported authentication schemes.

此外,Authorization 标头的格式应为 GoogleLogin auth= 其中 来自 ClientLogin 响应的 code>Auth 值.

Additionally, the Authorization header should be formatted as GoogleLogin auth=<auth token> where <auth token> is the Auth value from the ClientLogin response.

这篇关于访问谷歌阅读器的端点 API 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆