Buda az önce Asp.net ile verdiğimiz örneğin PHP ile Hava Durumu örneği.
Bu verileri alıp sitenizin tasarım yapısına uyarlamak size kalmış.
hava.php sayfamız
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<?PHP require_once("hava_cs.php"); ?>
</body>
</html>
hava_cs.php sayfamız
<?PHP
class hava_cs
{
function __construct()
{
print $this -> havaDurumu("TUXX0014","10");
//Hava Durumu için oluşturduğumuz fonksyonunda, ilk değer istediğimiz ilin id numarası, yukarıdaki id İstanbul'un.
// İzmir TUXX0015
// Antalya TUXX0004
//İkinci değer ise kaç günlük çekmek istiyorsak, 10 gün için, 10 dedik.
}
private $pid = "burayauyeid";
private $lk = "burayauyesifresi";
private function havaServisi($a,$b)
{
$url = 'http://xml.weather.com/weather/local/'.$a.'?cc=*&dayf='.$b.'&link=xoap&prod=xoap
&par='.$this -> pid.'&key='.$this -> lk.'&unit=m';
return simplexml_load_file($url);
}
private $rsm = 'http://i.imwx.com/web/common/wxicons/31/';
private function havaDurumu($a,$z)
{
$xml = $this -> havaServisi($a,$z);
$result["icon1"] = $xml -> xpath("/weather/cc/icon");
$result["tmp"] = $xml -> xpath("/weather/cc/tmp");
$s = 'Hava<br/><img src="'.$this -> rsm . $result["icon1"][0] . '.gif'.'" alt="" />
'.$result["tmp"][0].' °<br/><br/>';
$result["low"] = $xml -> xpath("/weather/dayf/day/low");
$result["hi"] = $xml -> xpath("/weather/dayf/day/hi");
$result["icon2"] = $xml -> xpath("/weather/dayf/day/part/icon");
for ($a=2;$a<count($result["icon2"]);$a++)
{
if ($a % 2 == 0)
{
$t++;
$s .= date("d.m.Y",mktime (0,0,0,date("m") ,date("d")+$t,date("Y"))).'<br/>';
$s .= '<img src="'.$this -> rsm . $result["icon2"][$a] . '.gif'.'" alt="" />
'. $result["low"][$t].' ° / '.$result["hi"][$t].' °<br/><br/>';
}
}
return $s;
}
}
$hava_cs = new hava_cs();
?>
0 yorum:
Yorum Gönder