天气插件

http://tianqi.2345.com/plugin/

方法1// $requesturl="http://www.weather.com.cn/data/sk/101320101.html";
// $ch = curl_init();
// // 设置URL和相应的选项
// curl_setopt($ch, CURLOPT_URL, $requesturl);
// curl_setopt($ch, CURLOPT_HEADER, 0);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $info=curl_exec($ch);
// // 关闭cURL资源,并且释放系统资源
// curl_close($ch);
// //对返回的json串进行decode,分解后与下面的数组一起合成json串
// $info=json_decode($info,true);
// var_dump($info);
// echo mb_convert_encoding($info['weatherinfo']['city'],'gb2312','UTF-8'); 
$city="香港";
方法2
$content = file_get_contents("http://api.map.baidu.com/telematics/v3/weather?location=%E9%A6%99%E6%B8%AF&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ");
$info = json_decode($content,true);
echo "<pre>";
print_r($info);
print_r($info['results'][0]['currentCity']);
print_r($info['results'][0]['weather_data']);


转载于:https://my.oschina.net/bibo/blog/314538

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值