如何在我的iPhone应用程序中搜索youtube上的视频? [英] How can I do a search for video on youtube in my iPhone app?

查看:190
本文介绍了如何在我的iPhone应用程序中搜索youtube上的视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,我想在youtube上搜索视频。

In my iPhone application, I want to do a search for video on youtube.

我该怎么做(使用GData API)?

How can I do this (with the GData API)?

推荐答案

你这样做就像你要求任何其他数据一样。如果我想从我的iPhone应用程序中搜索youtube视频,我会向youtube创建一个如下所示的请求:

You do it the same as you would ask for any other data. If I wanted to search for youtube videos from my iPhone application, I would create a request to youtube that looked like this:

-(void)fetchYoutubeData:(NSString *)myQuery{
//where myQuery is the string to search for
//it needs to be encoded to stick in the url so Jimi%20Hendrix instead
///of Jimi Hendrix
NSError *err = [[[NSError alloc] init] autorelease];
NSString *myRequest = [NSString stringWithFormat:@"http://gdata.youtube.com/feeds/api/videos?q=%@&max-results=5",myQuery]; 
NSURL *url = [NSURL URLWithString:myRequest];  
NSString *myYouTubeData = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&err];
if(err.code != 0) {
//HANDLE ERROR HERE
}
//Do Something with myYouTubeData here
}

您将需要解析您获得的 myYouTubeData 字符串。有关如何构建查询的完整指南,请参阅 YouTube API网页

You will need to parse the myYouTubeData string that you get back. The complete guide on how to structure your query can be found at the YouTube API webpage.

这篇关于如何在我的iPhone应用程序中搜索youtube上的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆