首页 历史天气 历史天气示例代码 历史天气查询[PHP]

历史天气查询示例代码[PHP]

作者: 阅读数:1118 上传时间:2018-04-04

历史天气查询

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$city = '安顺';//utf8
$cityid='111';//任选
$url = "http://api.binstd.com/weather2/query?appkey=$appkey&city=$city";
$result = curlOpen($url);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

$result = $jsonarr['result'];
echo $result['cityid'].' '.$result['date'].' '.$result['weather'].' '.$result['temphigh'].' '.$result['templow'].' '.$result['img'].' '.$result['humidity'].' '.$result['pressure'].' '.$result['windspeed'].' '.$result['winddirect'].' '.$result['windpower'].' '.$result['sunrise'].' '.$result['sunset'].' '.$result['aqi'].' '.$result['primarypollutant'].' '.$result['cityname'];