这两个插件操,太好使了
生成js粘贴就ok
第一种:
http://tianqi.2345.com/plugin/
http://www.tianqi.com/plugin/
第二种:
通过ip外网地址,获取城市的天气预报
<?php
class WeatherAction extends baseAction {
// public function index(){
// //获取北京天气
// header("content-type:text/html;charset=utf-8");
// $weather = file_get_contents("http://www.weather.com.cn/data/sk/101010100.html");
// echo $weather;
//}
/*
* 腾讯通过IP地址获取当前地理位置(省份)的接口
* 腾讯的接口是,返回数组 http://fw.qq.com/ipaddress
* 返回值 var IPData = new Array("71.131.122.114","","辽宁省","沈阳市");
*/
public function getIpAddress(){
$ipContent = file_get_contents("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js");
$jsonData = explode("=",$ipContent);
$jsonAddress = substr($jsonData[1], 0, -1);
return $jsonAddress;
}
public function index(){
//获取北京天气
header("content-type:text/html;charset=utf-8");
$city=json_decode($this->getIpAddress());
$city=$city->city;
$info=file_get_contents("http://www.360api.net/api/Weather.aspx?appkey=publickey&keyword=$city&format=json");
var_dump(json_decode($info));
}
}
?>