首先,我有这个获取 gdata 提要的 gdata url:
https://gdata.youtube.com/feeds/api/videos/tge2BfiIXiE?v=2&alt=jsonc
这是从 url 获取信息的代码:
NSURL *feedURL = [NSURL URLWithString:@"https://gdata.youtube.com/feeds/api/videos/tge2BfiIXiE?v=2&alt=jsonc"];
NSData *jsonData = [NSData dataWithContentsOfURL:feedURL];
NSError *error = nil;
NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
NSDictionary *data1 = [dataDictionary objectForKey:@"data"];
NSString *t = [data1 objectForKey:@"title"];
NSLog(@"Title:%@", t);
NSDictionary *thumbs = [dataDictionary objectForKey:@"thumbnail"];
NSURL *standardThumb = [thumbs objectForKey:@"sqDefault"];
NSURL *hdThumb = [thumbs objectForKey:@"hqDefault"];
上面的代码获取视频的标题。但是,该代码无法从 gdata url 成功获取缩略图。当我尝试访问NSLOG
该hdThumb
网址时,我只收到null
回复,所以我的问题是如何解决这个问题。