$fff ='https://www.googleapis.com/youtube/v3/channels?part=snippet&id='.$v.'&key=ключ';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $fff);
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');
Header("Content-Type: text/html;charset=UTF-8");
$json = json_decode($json, true) ;
// print_r($json);
if ($json['pageInfo']['totalResults'] == '0') { $title =''; } else { $title =$json['items']['0']['snippet']['title'] ; $title =urlencode($title); $v=$title; } ;
}
print_r($_POST);
$(function() {
$("#frm_details").on("submit", function(event) {
event.preventDefault();
$.ajax({
url: "send.php",
type: "post",
data: $(this).serialize(),
success: function(d) {
alert(d);
}
});
});
});
<form name="frm_details" id="frm_details" method="post">
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{ header('Content-Type: text/html; charset=utf-8');
if (isset($_POST['message'])) { $v=$_POST['message'];