我试图在两天之内使用Instagram获取图片。但我错了。
我写了像beolw的代码:
NSString * fromDate = @"2014 Aug 14 10:00:00";
NSString * toDate = @"2014 Aug 14 14:00:00";
NSDateFormatter * dateFmt = [[NSDateFormatter alloc] init];
[dateFmt setDateFormat:@"yyyy MMM dd HH:mm:ss"];
[dateFmt setTimeZone:[NSTimeZone systemTimeZone]];
NSDate * time1 = [dateFmt dateFromString:fromDate];
NSDate * time2 = [dateFmt dateFromString:toDate];
int fromInterval = [time1 timeIntervalSince1970];
int toInterval = [time2 timeIntervalSince1970];
NSLog(@"FROM %d TO %d",fromInterval,toInterval);//
NSString * urlString = [NSString stringWithFormat:@"https://api.instagram.com/v1/tags/%@/media/recent?count=33&&MIN_TIMESTAMP=%dMAX_TIMESTAMP=%d&client_id=CLIENT_ID",hashTag, fromInterval,toInterval];
NSURL *urlInstagram=[NSURL URLWithString:urlString];
NSData *data=[NSData dataWithContentsOfURL:urlInstagram];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
NSLog(@"respionse %@",json);
但它没有给出我期望的结果。它仅在8月16日回归。
答案 0 :(得分:0)
根据他们的api页http://instagram.com/developer/endpoints/tags/, / tags / media / recent不接受min_timestamp或max_timestamp
一种解决方案是获取标记图像(使用计数,如果很多)并根据created_time
进行过滤