//根据城市获取天气信息
function weather_api($city){
$host = "http://jisutqybmf.market.alicloudapi.com";//接口地址
$path = "/weather/query";//接口
$method = "GET";//请求方法
$appcode = "";//阿里云appcode
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "city=".$city;
$bodys = "";
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CU
PHP 根据城市获取天气信息 阿里云接口
最新推荐文章于 2024-05-23 08:59:23 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)