Skip to content

Instantly share code, notes, and snippets.

@Miri92
Created March 9, 2014 19:48
Show Gist options
  • Save Miri92/9453463 to your computer and use it in GitHub Desktop.
Save Miri92/9453463 to your computer and use it in GitHub Desktop.
baku weather yandex xml api
<?php
$city_id=37864; // id şəhər
$data_file="http://export.yandex.ru/weather-ng/forecasts/$city_id.xml"; // xml fayl ünvanı
$xml = simplexml_load_file($data_file);
// lazım olan parametrləri seçirik (Şəhər, tempratur)
$temp=$xml->fact->temperature;
$pic=$xml->fact->{"image-v3"};
if ($temp>0) {$temp='+'.$temp;}
?>
<style type="text/css">
#weather img {
float: left;
width: 48px;
height: 48px;
margin:0 10px 0 0;
}
#weather span {
display: block;
}
</style>
<div id="weather">
<img src="http://yandex.st/weather/1.1.78/i/icons/48x48/<?php echo $pic ?>.png" alt="">
<span>Bakıda hava</span>
<span><?php echo ("$temp<sup>o</sup>C"); ?></span>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment