Below code, I got title and description but I want image as well as how to get the main image of video from JSON data.
$videoid = 'cMC_PtgKDJE';
$apikey = 'xyzxyzxyz'; //My API key
$json = file_get_contents('https://www.googleapis.com/youtube/v3/videos?id='.$videoid.'&key='.$apikey.'&part=snippet');
$ytdata = json_decode($json);
print_r($ytdata);
echo '<h1>Title: ' . $ytdata->items[0]->snippet->title . '</h1>';
echo 'Description: ' . $ytdata->items[0]->snippet->description;
Each YouTube video has 4 generated images.You can create the url as fallows
https://img.youtube.com/vi/<video-id-here>/0.jpg
If you want high quality image then you can read following atricle
how to get a youtube video’s thumbnail image in high quality
How to get video id from youtube url
$url = "http://www.youtube.com/watch?v=7zWKm-LZWm4&feature=relate";
parse_str( parse_url( $url, PHP_URL_QUERY ), $url_vars );
echo $url_vars['v'];
// Output: 7zWKm-LZWm4
?>
Each video on YouTube provides several thumbnails of different quality
Default (for small thumbnails): $ytdata->items[0]->snippet->thumbnails->default->url;
Medium: $ytdata->items[0]->snippet->thumbnails->medium->url;
High: $ytdata->items[0]->snippet->thumbnails->high->url;
Standard: $ytdata->items[0]->snippet->thumbnails->standard->url;
Maximum resolution: $ytdata->items[0]->snippet->thumbnails->maxres->url;