M
M
MentozZz ORG2021-06-16 08:51:23
Yandex
MentozZz ORG, 2021-06-16 08:51:23

Yandex weather informer how to use?

Good afternoon everyone, I just woke up and found some code that should take
the weather from Yandex and paste it on the site, but I can’t understand how to use it that my head doesn’t cook at all

// Получаем ID города через поиск
$url = 'https://suggest-maps.yandex.ru/suggest-geo?callback=jQuery&v=8&lang=ru_RU&search_type=weather&part='.urlencode('Москва');
$getCities = file_get_contents($url);

$getCities = str_replace('jQuery(', '', $getCities);
$getCities = str_replace('])', ']', $getCities);
$arCities = json_decode($getCities, true);

// Получаем погоду найденных городов
foreach($arCities as $arCity) {
  $weatherXml = simplexml_load_file('https://export.yandex.ru/bar/reginfo.xml?region='.$arCity['geoid'].'&lang=ru');
  // Дальше уже обрабатываете полученный xml и выводите погоду
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question