You can also get the data i.e title, description, thumbnail_url, etc from the Youtube video url by using following script. Remember you need to put the YOUR_GOOGLE_DEVELOPMENT_KEY which you can generate by creating account in Google Developer Console.
PHP Script :-
$url = $data['url'];
if(strpos($url, 'https://youtube.com/embed/') === false){//OLD
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
$videoid = $my_array_of_vars['v'];
} else {//NEW
$urlArray = explode('https://youtube.com/embed/', $url);
$videoid = $urlArray[1];
}
$embedurl = "https://youtube.com/embed/".$videoid;
$json = json_decode( file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=".$videoid."&key=YOUR_GOOGLE_DEVELOPMENT_KEY&part=snippet,contentDetails,statistics,status") );
$data['title'] = $json->items[0]->snippet->title;
$data['description'] = $json->items[0]->snippet->description;
$data['thumbnail_url'] = $json->items[0]->snippet->thumbnails->medium->url;
$data['url'] = $embedurl;
0 Comment(s)