diff --git a/blocks/tag_youtube/block_tag_youtube.php b/blocks/tag_youtube/block_tag_youtube.php index 43037015363..4405afe8648 100644 --- a/blocks/tag_youtube/block_tag_youtube.php +++ b/blocks/tag_youtube/block_tag_youtube.php @@ -1,8 +1,7 @@ -dirroot.'/tag/lib.php'); require_once($CFG->libdir . '/filelib.php'); -require_once($CFG->libdir . '/phpxml/xml.php'); define('YOUTUBE_DEV_KEY', 'Dlp6qqRbI28'); define('DEFAULT_NUMBER_OF_VIDEOS', 5); @@ -36,6 +35,7 @@ class block_tag_youtube extends block_base { return $this->content; } + $text = ''; if(!empty($this->config->playlist)){ //videos from a playlist $text = $this->get_videos_by_playlist(); @@ -138,35 +138,29 @@ class block_tag_youtube extends block_base { } function fetch_request($request){ - $c = new curl(array('cache' => true, 'module_cache'=>'tag_youtube')); + $c = new curl(array('cache' => true, 'module_cache'=>'tag_youtube')); + $c->setopt(array('CURLOPT_TIMEOUT' => 3, 'CURLOPT_CONNECTTIMEOUT' => 3)); $response = $c->get($request); - $xmlobj = XML_unserialize($response); - return $this->render_video_list($xmlobj); + $xml = new SimpleXMLElement($response); + return $this->render_video_list($xml); } - function render_video_list($xmlobj){ + function render_video_list(SimpleXMLElement $xml){ $text = ''; $text .= '