欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php如何查詢(xún)水質(zhì)量

本篇內(nèi)容介紹了“php如何查詢(xún)水質(zhì)量”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

專(zhuān)注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)鄆城免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千多家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

php查詢(xún)水質(zhì)量的方法:1、注冊(cè)并開(kāi)通水質(zhì)API接口;2、配置申請(qǐng)的appkey;3、請(qǐng)求URL;4、獲取接口參數(shù);5、通過(guò)“function juhecurl($url,$params=false,$ispost=0){...}”等方式分析處理水質(zhì)接口數(shù)據(jù)即可。

php怎么查詢(xún)水質(zhì)量?

1、開(kāi)通水質(zhì)量API接口:

通過(guò)https://www.juhe.cn/docs/api/id/34?s=cpphpcn注冊(cè)及開(kāi)通

接口說(shuō)明:該接口支持全國(guó)大多數(shù)監(jiān)測(cè)站點(diǎn)水質(zhì)量查詢(xún),包括PH值、溶解氧、氨氮、高錳酸鉀指數(shù)及總有機(jī)碳含量等。有的監(jiān)測(cè)站點(diǎn)沒(méi)有總有機(jī)碳監(jiān)測(cè)數(shù)據(jù)。

接口地址:http://web.juhe.cn:8080/environment/water/river

返回格式:json

請(qǐng)求方式:get

請(qǐng)求示例:http://web.juhe.cn:8080/environment/water/river?river=流域名稱(chēng)&key=您申請(qǐng)的APPKEY值

2、基于php的水質(zhì)查詢(xún)api調(diào)用代碼實(shí)例

代碼如下:

header('Content-type:text/html;charset=utf-8');
//配置您申請(qǐng)的appkey
$appkey = "*********************";
//************1.流域查詢(xún)水質(zhì)量************
$url = "http://web.juhe.cn:8080/environment/water/river";
$params = array(
"river" => "",//流域名稱(chēng),查詢(xún)流域?yàn)椤伴L(zhǎng)江流域”,則輸入“長(zhǎng)江流域”
"key" => $appkey,//APP Key
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
if($result['error_code']=='0'){
print_r($result);
}else{
echo $result['error_code'].":".$result['reason'];
}
}else{
echo "請(qǐng)求失敗";
}
//**************************************************
//************2.監(jiān)測(cè)站點(diǎn)查詢(xún)水質(zhì)量************
$url = "http://web.juhe.cn:8080/environment/water/state";
$params = array(
"state" => "",//監(jiān)測(cè)站點(diǎn)名稱(chēng),查詢(xún)站點(diǎn)為“湖北宜昌南津關(guān)”,則輸入“湖北宜昌南津關(guān)”
"key" => $appkey,//APP Key
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
if($result['error_code']=='0'){
print_r($result);
}else{
echo $result['error_code'].":".$result['reason'];
}
}else{
echo "請(qǐng)求失敗";
}
//**************************************************
//************3.監(jiān)測(cè)站點(diǎn)列表************
$url = "http://web.juhe.cn:8080/environment/water/stateList";
$params = array(
"key" => $appkey,//應(yīng)用APPKEY
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
if($result['error_code']=='0'){
print_r($result);
}else{
echo $result['error_code'].":".$result['reason'];
}
}else{
echo "請(qǐng)求失敗";
}
//**************************************************
/**
* 請(qǐng)求接口返回內(nèi)容
* @param string $url [請(qǐng)求的URL地址]
* @param string $params [請(qǐng)求的參數(shù)]
* @param int $ipost [是否采用POST形式]
* @return string
*/
function juhecurl($url,$params=false,$ispost=0){
$httpInfo = array();
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if( $ispost )
{
curl_setopt( $ch , CURLOPT_POST , true );
curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
curl_setopt( $ch , CURLOPT_URL , $url );
}
else
{
if($params){
curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
}else{
curl_setopt( $ch , CURLOPT_URL , $url);
}
}
$response = curl_exec( $ch );
if ($response === FALSE) {
//echo "cURL Error: " . curl_error($ch);
return false;
}
$httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
$httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
curl_close( $ch );
return $response;
}

“php如何查詢(xún)水質(zhì)量”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

分享題目:php如何查詢(xún)水質(zhì)量
瀏覽路徑:http://www.chinadenli.net/article14/gshdge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)App開(kāi)發(fā)商城網(wǎng)站網(wǎng)站設(shè)計(jì)公司全網(wǎng)營(yíng)銷(xiāo)推廣網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)