PHP网页代理获取天气预报怎么实现? 5
<?php$xml=simplexml_load_file("http://php.weather.sina.com.cn/xml.php?city=%D5%F2%BD%...
<?php
$xml = simplexml_load_file("http://php.weather.sina.com.cn/xml.php?city=%D5%F2%BD%AD&password=DJOYnieT8234jlsK&day=0");
$html = "<p>City:{$xml->Weather->city}</p>";
$status1=$xml->Weather->status1;
$status2=$xml->Weather->status2;
$temperature1=$xml->Weather->temperature1;
$temperature2=$xml->Weather->temperature2;
$direction1=$xml->Weather->direction1;
$power1=$xml->Weather->power1;
$forecast = $status1.($status2!='' && strcmp($status1,$status2)==0
?"":"转".$status2).
" ".$temperature1."°C".($temperature2!='' && strcmp($temperature1,$temperature2)==0?"":"~".$temperature2."°C")." ".$direction1.$power1."级";
echo $forecast;
?>
这是原来的代码,直接访问新浪的,假如服务器不能直接访问外网,如何通过代理获取天气预报啊。。。添加什么代码呀。。。。求解答 展开
$xml = simplexml_load_file("http://php.weather.sina.com.cn/xml.php?city=%D5%F2%BD%AD&password=DJOYnieT8234jlsK&day=0");
$html = "<p>City:{$xml->Weather->city}</p>";
$status1=$xml->Weather->status1;
$status2=$xml->Weather->status2;
$temperature1=$xml->Weather->temperature1;
$temperature2=$xml->Weather->temperature2;
$direction1=$xml->Weather->direction1;
$power1=$xml->Weather->power1;
$forecast = $status1.($status2!='' && strcmp($status1,$status2)==0
?"":"转".$status2).
" ".$temperature1."°C".($temperature2!='' && strcmp($temperature1,$temperature2)==0?"":"~".$temperature2."°C")." ".$direction1.$power1."级";
echo $forecast;
?>
这是原来的代码,直接访问新浪的,假如服务器不能直接访问外网,如何通过代理获取天气预报啊。。。添加什么代码呀。。。。求解答 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询