2013-03-14 60 views
0

我一直在寻找谷歌数据的API,特别需要从Google日历中获取信息并将其导入到我创建的应用程序中(我只需要放置并存储现在的数据如下例所示将使用tableview)。我似乎无法找到对函数/方法的直接引用,以及他们做了什么使其非常恼人。有人能够引导我吗?我想要做的就是从日历中提取所有事件。没有编辑等。我甚至不确定我是否正朝着正确的方向前进。如何在iOS中抓取Google日历活动

-(void)fetchEntries{ 
    calendarService = [[GDataServiceGoogleCalendar alloc] init]; 

    NSString *username = @"Gmail Username"; 
    [calendarService setUserCredentialsWithUsername:username password:@"password"]; 
    NSURL *feedURL = [GDataServiceGoogleCalendar calendarFeedURLForUsername:username]; 

    GDataServiceTicket *ticket; 
    ticket = [calendarService fetchFeedWithURL:feedURL delegate:self didFinishSelector:@selector(ticket:finishedWithFeed:error:)]; 
    //ticket = [calendarService fetchFeedWithURL:feedURL delegate:self didFinishSelector:@selector(calendarEventsTicket:finishedWithEntries:error:)]; 

} 

- (void)ticket:(GDataServiceTicket *)ticket 
finishedWithFeed:(GDataFeedCalendar *)feed 
     error:(NSError *)error { 

    if (error == nil) { 
     NSArray *entries = [feed entries]; 
     if ([entries count] > 0) { 

      GDataEntryCalendar *firstCalendar = [entries objectAtIndex:0]; 
      GDataTextConstruct *titleTextConstruct = [firstCalendar title]; 
      NSString *title = [titleTextConstruct stringValue]; 

      NSString *description = [firstCalendar description]; 

      NSLog(@"first calendar's title: %@ and description: %@", title, description); 


      GDataLink *link = [firstCalendar alternateLink]; 
      [self beginFetchingFiveEventsFromCalendar:firstCalendar]; 

      if (link != nil) { 
//    [service fetchFeedWithURL:[link URL] delegate:self didFinishSelector:@selector(eventsTicket:finishedWithFeed:error:)]; 
       NSLog(@"\n\nAlternate link: %@", link); 
      } 
     } else { 
      NSLog(@"the user has no calendars"); 
     } 
    } else { 
     NSLog(@"fetch error: %@", error); 
    } 



} 

回答