public function getCity() {
$ip = $_SERVER["REMOTE_ADDR"];
$city = $this->getUrl('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='.$ip);
$cityarr = json_decode($city,true);
//城市名稱
$cityname = $cityarr['city'];
return $cityname;
}
public function getWeatherinfo() {
$cityname = $this->getCity();
$data = $this->getUrl('http://www.sojson.com/open/api/weather/json.shtml?city='.$cityname);
$weatherdata =json_decode($data,true);
天氣預報接口來自
新浪擷取經城市接口http://int.dpool.sina.com.cn