$fff2 ='https://www.googleapis.com/youtube/v3/search'.$region.'&'.$vpoisk.'&key=///////////////'.$rating.'&type=video&'.$time.'&part=snippet&safeSearch=none'. $kolisestvo.'
';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $fff2);
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP Bot');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
$json = curl_exec($ch);
curl_close($ch);
if ($json !== false) {
$json = preg_replace("#(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|([\s\t]//.*)|(^//.*)#", '', $json);
// setlocale(LC_ALL, 'ru_RU.utf8');
$json = json_decode($json, true) ;
// print_r($json);
if (isset($json['items']))
{
foreach($json['items'] as $items) {
$channelId =$items['snippet']['channelId'];
$publishedAt =$items['snippet']['publishedAt'];
$title =$items['snippet']['title'];
if (isset($items['snippet']['thumbnails']['default']['url']))
{ $thumbnails =$items['snippet']['thumbnails']['default']['url'];
if (isset($items['id']['videoId'])) {
$videoId =$items['id']['videoId'];