PHP code example of nextras / youtube-api

1. Go to this page and download the library: Download nextras/youtube-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nextras / youtube-api example snippets


$reader = new Nextras\YoutubeApi\Reader('<your google-api key>')
$video = $reader->getVideoByUrl('<youtube url>');

echo $video->title;
echo $video->duration; // in sec
echo $video->description;
echo $video->url;
echo $video->embed;
foreach ($video->thumbs as $thumb) {
    echo $video->url; 
}