$opts = array('http' =>
array(
'header' => "Content-Type: text/plain\r\n"
)
);
$context = stream_context_create($opts);
$str=file_get_contents("https://geocode-maps.yandex.ru/1.x/?geocode=27.525773,53.89079", false, $context);
print_r($str);
function geocode($coords) {
$myCurl = curl_init();
curl_setopt_array($myCurl, array(
CURLOPT_URL => 'https://geocode-maps.yandex.ru/1.x/?geocode='.$coords,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => false,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer 7EG9MK2rWO-puhTKXSBFk_P8LyW1L-K_',
'Content-Type: application/json'
)
));
$response = curl_exec($myCurl);
curl_close($myCurl);
return simplexml_load_string($response);
};
$xml = geocode('27.525773,53.89079');