Created
March 9, 2014 19:48
-
-
Save Miri92/9453463 to your computer and use it in GitHub Desktop.
baku weather yandex xml api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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