天气预报数据接口(天气预报接口api)

天气预报数据接口(天气预报接口api)lt php header Content Type text html charset UTF 8 function nowapiReques postData amp errMsg apiUrl https sapi k780 com amp

大家好,我是讯享网,很高兴认识大家。




讯享网

<?php
header("Content-Type:text/html;charset=UTF-8");
function nowapiRequest(\(postData,&\)errMsg=‘’){ 
讯享网$apiUrl = 'https://sapi.k780.com/'; $useContext = stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => http_build_query($postData) ) )); if(!$resData=file_get_contents($apiUrl,false,$useContext)){ $errMsg = 'ERR_CONNECT'; return false; } if(!$arrData=json_decode($resData,true)){ $errMsg = 'ERR_DECODE'; return false; } if($arrData['success']!=1){ $errMsg = $arrData['msgid'].' '.$arrData['msg']; return false; } return $arrData['result']; 
} \(postData['app'] = 'weather.future'; \)postData[‘weaId’] = ‘1’; \(postData['appkey'] = '10003';//替换成自己的appkey \)postData[‘sign’] = ‘b59bc3ef6191eb9f747dd4e83c99f2a4’;//替换成自己的sign \(postData['format'] = 'json'; \)result = nowapiRequest(\(postData,\)errMsg); print_r(\(errMsg); print_r(\)result);

讯享网

小讯
上一篇 2025-04-23 09:56
下一篇 2025-06-06 15:12

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/177082.html