我正在开发一个使用gdata-objective-c-client和oauth 2.0连接谷歌的应用。我想显示用户的电子表格。我正在查看http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Examples/#Examples%2FDocsSample以查看如何使用oauth,我能够列出所有文档和电子表格,但我只是想显示电子表格,所以我更改了服务,但是我收到错误,没有显示任何内容。
这是我的代码:
@implementation ViewController
@synthesize accessToken;
@synthesize mDoclistFetchTicket;
@synthesize mWorksheetFeed;
@synthesize mSpreadsheetFeed;
static NSString *const kMyClientID = @"199740745364-22lugf8undgv0rc0ucbfpgsn3v90lfsd.apps.googleusercontent.com";
static NSString *const kMyClientSecret = @"dPFs5D66kLyQIgUNL6igKUoX";
static NSString *const kKeychainItemName = @"casa";
- (GDataServiceGoogleSpreadsheet *)spreadsheetService {
static GDataServiceGoogleSpreadsheet* service = nil;
if (!service) {
service = [[GDataServiceGoogleSpreadsheet alloc] init];
[service setShouldCacheResponseData:YES];
[service setServiceShouldFollowNextLinks:YES];
}
return service;
}
- (void) mifetch {
GDataServiceGoogleSpreadsheet *service = [self spreadsheetService];
GDataServiceTicket *ticket;
//HERE IS WHERE I GET THE ERROR
NSURL *feedURL = [NSURL URLWithString: kGDataGoogleSpreadsheetsPrivateFullFeed];
ticket = [service fetchFeedWithURL:feedURL
delegate:self
didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
mDoclistFetchTicket = ticket;
}
- (void) ticket: (GDataServiceTicket *) ticket
finishedWithFeed: (GDataFeedSpreadsheet *) feed
error: (NSError *) error {
mSpreadsheetFeed = feed;
}
- (void)authorize {
NSString *scope = @"https://spreadsheets.google.com/feeds";
GTMOAuth2ViewControllerTouch *windowController = [[GTMOAuth2ViewControllerTouch alloc]
initWithScope:scope
clientID:kMyClientID
clientSecret:kMyClientSecret
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[[self navigationController] pushViewController:windowController animated:YES];
}
- (IBAction)autenticarse
{
[self authorize];
}
- (IBAction)listar:(id)sender
{
[self performSegueWithIdentifier:@"displaydocs" sender:sender];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"displaydocs"])
{
VistaTableViewController *vistatableview = [segue destinationViewController];
vistatableview.delegate = self;
vistatableview.mSpreadsheetFeed2 = mSpreadsheetFeed;
}
}
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error
{
[[self docsService] setAuthorizer:auth];
[self mifetch];
}
@end
这就是Xcode所说的:
serviceBase:objectFetcher:GTMHTTPFetcher 0xe5c7580(https://spreadsheets.google.com/feeds/spreadsheets/private/full)failedWithStatus:404 data
首先,当我展示文档和电子表格时,我使用了像这样的GDataServiceGoogleDocs:
- (GDataServiceGoogleDocs *)docsService {
static GDataServiceGoogleDocs* service = nil;
if (!service) {
service = [[GDataServiceGoogleDocs alloc] init];
[service setShouldCacheResponseData:YES];
[service setServiceShouldFollowNextLinks:YES];
[service setIsServiceRetryEnabled:YES];
}
return service;
}
并创建de feedURL我使用了这个:
NSURL *feedURL = [GDataServiceGoogleDocs docsFeedURL];
但是,我必须使用什么feedUR来显示电子表格?
谢谢!