目前我使用的是以下内容,这对于多个剪辑来说似乎相当慢:
static function get_yt_title($clip_id){
$feedURL = 'http://gdata.youtube.com/feeds/api/videos/' . $clip_id;
$entry = @simplexml_load_file($feedURL);
if($entry){
$video= new stdClass;
$media = $entry->children('http://search.yahoo.com/mrss/');
$video->title = ucwords(strtolower($media->group->title));
return $video->title;
}
else{
return FALSE;
}有没有比这更有效的方法来用php一次做5-10个剪辑?
发布于 2010-07-14 19:42:33
是。
静态函数get_yt_title($clip_id) { $entry = @simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/‘.$clip_id);返回($entry)?ucwords(strtolower($entry->children('http://search.yahoo.com/mrss/')->group->title)):false;}
使用JSON提要:通过将?alt=json附加到URI来实现http://gdata.youtube.com/feeds/api/videos/?alt=json
发布于 2010-07-14 19:30:42
我不认为有。据我所知,这是获取这样的元数据的推荐方法。
我还能想到另外一件事,那就是从youtube.com上刮掉html,我几乎可以向你保证,它不会更快,而且肯定是地狱不可靠。
发布于 2010-07-14 21:28:42
如果你对相同的剪辑id做了很多这样的操作,你可以在你的服务器上缓存结果。
https://stackoverflow.com/questions/3245556
复制相似问题