Ios 按频道名称检索YouTube频道视频
我正在Youtube数据API V3中寻找两个API调用 首先,我想通过指定通道的名称来获取通道ID 一旦我有了频道ID,我想从该频道获得n个视频 我正在寻找我必须进行的API调用 还有,有人知道频道或视频ID是否有可能在某个时刻发生变化吗?如果它们可以更改为同一视频/频道,则我不应硬编码代码中的ID 谢谢第一次呼叫是a,将q设置为频道名称,并键入=“频道” 第二个是用这个id打电话,获取上传视频列表的播放id 第三个选项是在该播放列表下列出视频。第一个调用是设置q为频道名称并键入=“channel” 第二个是用这个id打电话,获取上传视频列表的播放id 第三个选项是在该播放列表下列出视频。第一个调用是设置q为频道名称并键入=“channel” 第二个是用这个id打电话,获取上传视频列表的播放id 第三个选项是在该播放列表下列出视频。第一个调用是设置q为频道名称并键入=“channel” 第二个是用这个id打电话,获取上传视频列表的播放idIos 按频道名称检索YouTube频道视频,ios,youtube,youtube-api,youtube-data-api,youtube-channels,Ios,Youtube,Youtube Api,Youtube Data Api,Youtube Channels,我正在Youtube数据API V3中寻找两个API调用 首先,我想通过指定通道的名称来获取通道ID 一旦我有了频道ID,我想从该频道获得n个视频 我正在寻找我必须进行的API调用 还有,有人知道频道或视频ID是否有可能在某个时刻发生变化吗?如果它们可以更改为同一视频/频道,则我不应硬编码代码中的ID 谢谢第一次呼叫是a,将q设置为频道名称,并键入=“频道” 第二个是用这个id打电话,获取上传视频列表的播放id 第三个选项是在该播放列表下列出视频。第一个调用是设置q为频道名称并键入=“chann
第三是在播放列表下的列表视频。
< P>对于想要运行示例的所有新手来说:考虑一个有助于理解获取、解析、显示等整个循环的功能,并具体地将YouTube频道的视频带到您的TabLeVIEW中。我不是在这里写tableview部分-(void)initiateRequestToYoutubeApiAndGetChannelInfo
{
NSString * urlYouCanUseAsSample = @"https://www.googleapis.com/youtube/v3/search?key={YOUR_API_KEY_WITHOUT_CURLY_BRACES}&channelId={CHANNEL_ID_YOU_CAN_GET_FROM_ADDRESS_BAR_WITHOUT_CURLY_BRACES}&part=snippet,id&order=date&maxResults=20";
NSURL *url = [[NSURL alloc] initWithString: urlYouCanUseAsSample];
// Create your request
NSURLRequest *request = [NSURLRequest requestWithURL:url];
// Send the request asynchronously remember to reload tableview on global thread
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
// Callback, parse the data and check for errors
if (data && !connectionError) {
NSError *jsonError;
NSDictionary *jsonResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
if (!jsonError) {
// better put a breakpoint here to see what is the result and how it is brought to you. Channel id name etc info should be there
NSLog(@"%@",jsonResult);
/// separating "items" dictionary and making array
//
id keyValuePairDict = jsonResult;
NSMutableArray * itemList = keyValuePairDict[@"items"];
for (int i = 0; i< itemList.count; i++) {
/// separating VIDEO ID dictionary from items dictionary and string video id
id v_id0 = itemList[i];
NSDictionary * vid_id = v_id0[@"id"];
id v_id = vid_id;
NSString * video_ID = v_id[@"videoId"];
//you can fill your local array for video ids at this point
// [video_IDS addObject:video_ID];
/// separating snippet dictionary from itemlist array
id snippet = itemList[i];
NSDictionary * snip = snippet[@"snippet"];
/// separating TITLE and DESCRIPTION from snippet dictionary
id title = snip;
NSString * title_For_Video = title[@"title"];
NSString * desc_For_Video = title[@"description"];
//you can fill your local array for titles & desc at this point
// [video_titles addObject:title_For_Video];
// [video_description addObject:desc_For_Video];
/// separating thumbnail dictionary from snippet dictionary
id tnail = snip;
NSDictionary * thumbnail_ = tnail[@"thumbnails"];
/// separating highresolution url dictionary from thumbnail dictionary
id highRes = thumbnail_;
NSDictionary * high_res = highRes[@"high"];
/// separating HIGH RES THUMBNAIL IMG URL from high res dictionary
id url_for_tnail = high_res;
NSString * thumbnail_url = url_for_tnail[@"url"];
//you can fill your local array for titles & desc at this point
[video_thumbnail_url addObject:thumbnail_url];
}
// reload your tableview on main thread
//[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
performSelectorOnMainThread:@selector(reloadInputViews) withObject:nil waitUntilDone:NO];
// you can log all local arrays for convenience
// NSLog(@"%@",video_IDS);
// NSLog(@"%@",video_titles);
// NSLog(@"%@",video_description);
// NSLog(@"%@",video_thumbnail_url);
}
else
{
NSLog(@"an error occurred");
}
}
}];
}
-(无效)向您的TubeAppiandGetChannel信息发起请求
{
NSString*URLYOUCANSAMPLE=@”https://www.googleapis.com/youtube/v3/search?key={YOUR_API_KEY_不带花括号}&channelId={CHANNEL_ID_你可以从没有花括号的地址栏中获取}&part=snippet,ID&order=date&maxResults=20”;
NSURL*url=[[NSURL alloc]initWithString:urlYouCanUseAsSample];
//创建您的请求
NSURLRequest*request=[nsurlRequestRequestWithURL:url];
//异步发送请求记住在全局线程上重新加载tableview
[NSURLConnection sendAsynchronousRequest:请求队列:[[NSOperationQueue alloc]init]completionHandler:^(NSURResponse*response,NSData*data,NSError*connectionError){
//回调,解析数据并检查错误
if(数据和连接错误){
n错误*jsonError;
NSDictionary*jsonResult=[NSJSONSerialization JSONObjectWithData:数据选项:NSJSONReadingMutableContainers错误:&jsonError];
如果(!jsonError){
//最好在这里放一个断点,看看结果是什么,以及它是如何带给你的。频道id名称等信息应该在那里
NSLog(@“%@”,jsonResult);
///分离“项”字典并生成数组
//
id keyValuePairDict=jsonResult;
NSMutableArray*itemList=keyValuePairDict[@“items”];
对于(int i=0;i 对于想要一个运行示例的所有新手来说:考虑一个有助于理解整个获取、解析、显示等循环的功能,并将YouTube频道的视频具体地带到您的TabLeVIEW中。我不是在这里写tableview部分
-(void)initiateRequestToYoutubeApiAndGetChannelInfo
{
NSString * urlYouCanUseAsSample = @"https://www.googleapis.com/youtube/v3/search?key={YOUR_API_KEY_WITHOUT_CURLY_BRACES}&channelId={CHANNEL_ID_YOU_CAN_GET_FROM_ADDRESS_BAR_WITHOUT_CURLY_BRACES}&part=snippet,id&order=date&maxResults=20";
NSURL *url = [[NSURL alloc] initWithString: urlYouCanUseAsSample];
// Create your request
NSURLRequest *request = [NSURLRequest requestWithURL:url];
// Send the request asynchronously remember to reload tableview on global thread
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
// Callback, parse the data and check for errors
if (data && !connectionError) {
NSError *jsonError;
NSDictionary *jsonResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
if (!jsonError) {
// better put a breakpoint here to see what is the result and how it is brought to you. Channel id name etc info should be there
NSLog(@"%@",jsonResult);
/// separating "items" dictionary and making array
//
id keyValuePairDict = jsonResult;
NSMutableArray * itemList = keyValuePairDict[@"items"];
for (int i = 0; i< itemList.count; i++) {
/// separating VIDEO ID dictionary from items dictionary and string video id
id v_id0 = itemList[i];
NSDictionary * vid_id = v_id0[@"id"];
id v_id = vid_id;
NSString * video_ID = v_id[@"videoId"];
//you can fill your local array for video ids at this point
// [video_IDS addObject:video_ID];
/// separating snippet dictionary from itemlist array
id snippet = itemList[i];
NSDictionary * snip = snippet[@"snippet"];
/// separating TITLE and DESCRIPTION from snippet dictionary
id title = snip;
NSString * title_For_Video = title[@"title"];
NSString * desc_For_Video = title[@"description"];
//you can fill your local array for titles & desc at this point
// [video_titles addObject:title_For_Video];
// [video_description addObject:desc_For_Video];
/// separating thumbnail dictionary from snippet dictionary
id tnail = snip;
NSDictionary * thumbnail_ = tnail[@"thumbnails"];
/// separating highresolution url dictionary from thumbnail dictionary
id highRes = thumbnail_;
NSDictionary * high_res = highRes[@"high"];
/// separating HIGH RES THUMBNAIL IMG URL from high res dictionary
id url_for_tnail = high_res;
NSString * thumbnail_url = url_for_tnail[@"url"];
//you can fill your local array for titles & desc at this point
[video_thumbnail_url addObject:thumbnail_url];
}
// reload your tableview on main thread
//[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
performSelectorOnMainThread:@selector(reloadInputViews) withObject:nil waitUntilDone:NO];
// you can log all local arrays for convenience
// NSLog(@"%@",video_IDS);
// NSLog(@"%@",video_titles);
// NSLog(@"%@",video_description);
// NSLog(@"%@",video_thumbnail_url);
}
else
{
NSLog(@"an error occurred");
}
}
}];
}
-(无效)向您的TubeAppiandGetChannel信息发起请求
{
NSString*URLYOUCANSAMPLE=@”https://www.googleapis.com/youtube/v3/search?key={YOUR_API_KEY_不带花括号}&channelId={CHANNEL_ID_你可以从没有花括号的地址栏中获取}&part=snippet,ID&order=date&maxResults=20”;
NSURL*url=[[NSURL alloc]initWithString:urlYouCanUseAsSample];
//创建您的请求
NSURLRequest*request=[NSURLRequest requestWithURL:u