2

我正在开发一个使用 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 数据

起初,当我展示文档和电子表格时,我使用了这样的 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];

但是,我必须使用什么 feedURL 来显示电子表格?

谢谢!!

4

0 回答 0