В curl_execute возвращается [content_type] => text/html; charset=UTF-8
Я с одного домена пытаюсь связаться с другим доменам и получить данные в json формате с помощью cURL.
часть кода домена, с которого происходит обращение:
$URL='http://mysite.ru/rest/get-client-images-sizes';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$headers = array(
// 'Content-Type: application/json; charset=UTF-8',
'Accept:application/json',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
$result=curl_exec($ch);
if($result === FALSE) echo 'cURL Error: ' . curl_error($ch);
//Закрытие сеанса cURL
else echo "ok";
$info = curl_getinfo($ch);
print_r($info);
curl_close ($ch);
echo $result;
Плюс html - код страницы
Код второго домена с routing http://mysite.ru/rest/get-client-images-sizes
public function getClientImagesSizes(){
$img_url_array = [
0 => 'infodata---005-008-19-2-1---algus1---1-DSCN2675.jpg',
1 => 'infodata---005-008-19-2-1---algus1---DSCN2679.jpg',
2 => 'infodata---005-008-19-2-1---algus1---DSCN2682.jpg',
3 => 'infodata---005-008-19-2-1---algus1---DSCN2690.jpg',
];
$json = json_encode($img_url_array);
return new JsonResponse([ 'data' => $json, 'method' => 'GET', 'status'=> 200]);
Подскажите, почему Возвращается html код, а не переменная $json?
