getMessage(); } // The method which finds the video ID function getLiveVideoID() { global $channelID; $videoId = null; // Fetch the livestream page if($data = file_get_contents('https://youtube.com/embed/live_stream?channel='.$channelID)) { // Find the video ID in there if(preg_match('/\'VIDEO_ID\': \"(.*?)\"/', $data, $matches)) $videoId = $matches[1]; else throw new Exception("Couldn't find video ID"); } else throw new Exception("Couldn't fetch data"); return $videoId; } ?>