array(6) {
["kind"]=>
string(26) "youtube#searchListResponse"
["etag"]=>
string(57) ""5C5HHOaBSHC5ZXfkrT4ZlRCi01A/vQo46UYQvzVROP054AMvBCk5UO0""
["nextPageToken"]=>
string(6) "CAIQAA"
["regionCode"]=>
string(2) "RU"
["pageInfo"]=>
array(2) {
["totalResults"]=>
int(1000000)
["resultsPerPage"]=>
int(2)
}
["items"]=>
array(2) {
[0]=>
array(4) {
["kind"]=>
string(20) "youtube#searchResult"
["etag"]=>
string(57) ""5C5HHOaBSHC5ZXfkrT4ZlRCi01A/2FVBt7uUA5gvBBapV6QqRnSu2Wo""
["id"]=>
array(2) {
["kind"]=>
string(13) "youtube#video"
["videoId"]=>
string(11) "h2Nq0qv0K8M"
}
["snippet"]=>
array(7) {
["publishedAt"]=>
string(24) "2012-12-18T17:48:17.000Z"
["channelId"]=>
string(24) "UCGnKyJ7EZJ7vL_PXkOGLUxw"
["title"]=>
string(75) "Lecture 1 "PHP". Building Dynamic websites. Harvard OpencourseWare. CS E-75"
["description"]=>
string(138) "For Latest Lecture video (updated): http://www.youtube.com/watch?v=fJ7ULOFBBTM&list=PLvJoKWRPIu8GhAhDBAH0BFB9BS7YxM1W Building dynamic ..."
["thumbnails"]=>
array(3) {
["default"]=>
array(3) {
["url"]=>
string(46) "https://i.ytimg.com/vi/h2Nq0qv0K8M/default.jpg"
["width"]=>
int(120)
["height"]=>
int(90)
}
["medium"]=>
array(3) {
["url"]=>
string(48) "https://i.ytimg.com/vi/h2Nq0qv0K8M/mqdefault.jpg"
["width"]=>
int(320)
["height"]=>
int(180)
}
["high"]=>
array(3) {
["url"]=>
string(48) "https://i.ytimg.com/vi/h2Nq0qv0K8M/hqdefault.jpg"
["width"]=>
int(480)
["height"]=>
int(360)
}
}
["channelTitle"]=>
string(8) "Asim Ali"
["liveBroadcastContent"]=>
string(4) "none"
}
}
[1]=>
array(4) {
["kind"]=>
string(20) "youtube#searchResult"
["etag"]=>
string(57) ""5C5HHOaBSHC5ZXfkrT4ZlRCi01A/61IGoyy9CYaXiGz0BQsUhRr3u2E""
["id"]=>
array(2) {
["kind"]=>
string(15) "youtube#channel"
["channelId"]=>
string(24) "UCJbPGzawDH1njbqV-D5HqKw"
}
["snippet"]=>
array(7) {
["publishedAt"]=>
string(24) "2008-02-04T16:09:31.000Z"
["channelId"]=>
string(24) "UCJbPGzawDH1njbqV-D5HqKw"
["title"]=>
string(12) "thenewboston"
["description"]=>
string(75) "Tons of sweet computer related tutorials and some other awesome videos too!"
["thumbnails"]=>
array(3) {
["default"]=>
array(1) {
["url"]=>
string(107) "https://yt3.ggpht.com/--n5ELY2uT-U/AAAAAAAAAAI/AAAAAAAAAAA/d9JvaIEpstw/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
}
["medium"]=>
array(1) {
["url"]=>
string(108) "https://yt3.ggpht.com/--n5ELY2uT-U/AAAAAAAAAAI/AAAAAAAAAAA/d9JvaIEpstw/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
}
["high"]=>
array(1) {
["url"]=>
string(108) "https://yt3.ggpht.com/--n5ELY2uT-U/AAAAAAAAAAI/AAAAAAAAAAA/d9JvaIEpstw/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
}
}
["channelTitle"]=>
string(12) "thenewboston"
["liveBroadcastContent"]=>
string(4) "none"
}
}
}
}
if( $curl = curl_init() and $_POST['search']) {
curl_setopt($curl, CURLOPT_URL, 'https://www.googleapis.com/youtube/v3/search?part=snippet&q=php&key=AIzaSyDdu2ZBRB7ZWvLYnArIvrUCqqYA7ES9zYg&maxResults=2'); // maxResults - количество материала order - сортировка по: viewCount - число просмотров, Date - дата загрузки type = video только видео
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec($curl);
$obj = json_decode($out,true);
echo "<pre>";
var_dump($obj);
echo "</pre>";
for($i = 0; $i < 20; $i++) {
$video_id = $obj['items'][$i]['id']['videoId'];
echo $video_id;
if(!isset($video_id))
{
} else {
echo $video_id . "<br>";
}
}
curl_close($curl);
}
Получил ответ от Youtube Api, я смог вызволить ид видео, но не могу получить channelTitle, publishedAt и title, трудно понять вложенность + как вывести всё видео в форме от Youtube, если при вставке обычным плеером он "съедает" часть массивов?