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.
}
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??
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;
}