I am using this API to create an online image gallery for my application but the problem is I need create a dynamic gallery this code from sample code shows just a few images from flickr, I need show images from a URL here is the code:
For example: www.mysite.com/gallery
And on this URL there are many photos!
- (id)init {
self = [super init];
if (self) {
// Create a 2-dimensional array. First element of
// the sub-array is the full size image URL and
// the second element is the thumbnail URL.
images_ = [[NSArray alloc] initWithObjects:
[NSArray arrayWithObjects:@"http://farm5.static.flickr.com/4001/4439826859_19ba9a6cfa_o.jpg", @"http://farm5.static.flickr.com/4001/4439826859_4215c01a16_s.jpg", nil],
[NSArray arrayWithObjects:@"http://farm4.static.flickr.com/3427/3192205971_0f494a3da2_o.jpg", @"http://http://farm4.static.flickr.com/3427/3192205971_0f494a3da2_o.jpg" , nil];
}
return self;
}
#pragma mark -
#pragma mark KTPhotoBrowserDataSource
- (NSInteger)numberOfPhotos {
NSInteger count = [images_ count];
return count;
}
- (void)imageAtIndex:(NSInteger)index photoView:(KTPhotoView *)photoView {
NSArray *imageUrls = [images_ objectAtIndex:index];
NSString *url = [imageUrls objectAtIndex:FULL_SIZE_INDEX];
[photoView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"photoDefault.png"]];
}
- (void)thumbImageAtIndex:(NSInteger)index thumbView:(KTThumbView *)thumbView {
NSArray *imageUrls = [images_ objectAtIndex:index];
NSString *url = [imageUrls objectAtIndex:THUMBNAIL_INDEX];
[thumbView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"photoDefault.png"]];
}
Does the gallery website return json or xml? If it does not then you would need to read HTML returned from the gallery website and retrieve image tags. You can use http://github.com/topfunky/hpple/tree/master or http://github.com/zootreeves/Objective-C-HMTL-Parser to parse HTML. For simple HTML this approach should work.
If the HTML is complex then use YQL to scrape the gallery website and convert to JSON.