简体   繁体   中英

GData Picasa Photo Album iPhone

I was hoping someone could help me with this problem. I am trying to access a Picasa Web Album from my iphone application. I have used GData previously with Google Calendar and getting events and the data related to them before, so I set up my methods in a similar fashion. I however am getting an error that is telling me the following

serviceBase:<GDataServiceGooglePhotos: 0x4d4e6d0> objectFetcher:<GDataHTTPFetcher: 0xbaa35c0> failedWithStatus:400 data:Too many results requested

I am think that I have narrowed down the problem that I am having has something to do with the ticket that I am using, in the following line

ticket = [service fetchFeedWithURL:[NSURL URLWithString:kGDataGooglePhotosAllFeed]
                          delegate:self
                 didFinishSelector:@selector(photosListTicket:finishedWithFeed:error:)];

I however am unable to get past this problem. Does anyone have a suggestion to get past this problem. Am I doing something wrong?

My full code for the retrieval of the pictures is shown below. Anywhere that says picAlbum, that is a predefined NSArray to hold the information.

- (GDataServiceGooglePhotos *)photoService {

    static GDataServiceGooglePhotos* service = nil;
    if (!service) {
        service = [[GDataServiceGooglePhotos alloc] init];
        [service setShouldCacheDatedData:YES];
        [service setServiceShouldFollowNextLinks:YES];
    }

    [service setUserCredentialsWithUsername:@"username"
                                   password:@"password"];
    return service;
}


-(void)loadGooglePhotos {
    [self fetchAllPhotos];
}

-(void)fetchAllPhotos {
    NSLog(@"In fetchAllPhotos");
    GDataServiceGooglePhotos *service = [self photoService];
    GDataServiceTicket *ticket;

    ticket = [service fetchFeedWithURL:[NSURL URLWithString:kGDataGooglePhotosKindAlbum]
                              delegate:self
                     didFinishSelector:@selector(photosListTicket:finishedWithFeed:error:)];
}

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

    NSLog(@"In photosListTicket");
    NSArray *photos = [feed entries];
    if ([photos count] != 0){
        self.picAlbum = [photos objectAtIndex:0];
        NSLog(@"fetching photos");
        [self fetchPhotos];
    }
    else {
        NSLog(@"User has no photos...");
    }
}

- (void)fetchPhotos {

    NSLog(@"In fetchPhotos");
    if (self.picAlbum) {
        NSURL *feedURL = [[self.picAlbum alternateLink] URL];
        if (feedURL) {
            NSLog(feedURL);
            GDataQueryGooglePhotos *query = [GDataQueryGooglePhotos photoQueryWithFeedURL:feedURL];
            [query setMaxResults:1000];
            GDataServiceGooglePhotos *service = [self photoService];
            GDataServiceTicket *ticket;
            ticket = [service fetchFeedWithQuery:query delegate:self didFinishSelector:@selector(photosEventsTicket:finishedWithFeed:error:)];
        }
    }
}

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

    NSLog(@"In photosEventsTicket");
    NSArray *photos = [feed entries];
    NSLog([NSString stringWithFormat:@"%i",[photos count]]);
}

Thanks in advance for any information or help that you can provide.

If the server says "Too many results requested" that's a clue that the max results query parameter is too big.

The fetches in the code snippet do not appear functional. Neither kGDataGooglePhotosKindAlbum nor an album's alternateLink would be URLs for feeds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM