?? ???? ??? ????? ?? PHP ??
Oct 22, 2016 am 12:00 AMPHP ?? ?? ???? API ??? ?? ?? ??
? ?? ??? PHP ?? ?? ??? ?? ???? API ??? ??? ?? ?? ?????.
①: https://www.juhe.cn/docs/api/id/39
?? ???? API ??? ?????.
?? ???? ???? ?? ?? ????, ?? ?? ?? ?? ????, IP ?? ?? ?? ?? ??, GPS ?? ?? ?? ??, ??? 3?? ?? ?? ??? ???? ????. ??. ?? ??? ?? ?? ?? ??? ?? ?????. ?? ??? ???? ?? ?? ??? ??? ?? ?? ?????? ???? ??? ? ????.
??, ???? ?? ?? ??? header('Content-type:text/html;charset=utf-8');??<br>
include?'class.juhe.weather.php';?//引入天氣請求類??<br>
??<br>
//接口基本信息配置??<br>
$appkey?=?'**********';?//您申請的天氣查詢appkey??<br>
$weather?=?new?weather($appkey);??
header('Content-type: text/html;charset=utf-8')? ?????.
include 'class.juhe.weather.php'; //?? ?? ??? ??
$citysResult?=?$weather->getCitys();??<br>
if($citysResult['error_code']?==?0){????//以下可根據(jù)實際業(yè)務(wù)需求,自行改寫??<br>
????//////////////////////////////////////////////////////////////////////??<br>
????$citys?=?$citysResult['result'];??<br>
????foreach($citys?as?$ckey?=>$c){??<br>
????????echo?"ID:".$c['id'].",省份:".$c['province'].",城市:".$c['city'].",區(qū)域:".$c['district']."<br>";??<br>
????}??<br>
}else{????//以下可根據(jù)實際業(yè)務(wù)需求,自行改寫??<br>
????//////////////////////////////////////////////////////////////////////??<br>
????echo?$citysResult['error_code'].":".$citysResult['reason'];??<br>
}??
//????? ???? ??
$appkey = '************'; //???? ?? ?? ??
$weather = new Weather($appkey)
1. ???? ?? ?? ????
???? ?? ??? ????? ??? ??? ?? ???, ??? ??? ??? ??????? ??? ? ???? ?? API? ??? ??? ????.
$citysResult = $weather->getCitys()
if($citysResult['error_code'] == 0){ //??? ?? ???? ??? ?? ?? ??? ? ????
///////////////////////////////////////////////// //// /////////////////////
$citys = $citysResult['??']
foreach($citys as $ckey =>$c){
echo "ID: ".$c['id'].", ?: ".$c['province'].", ??: ".$c['city'].", ??: ".$c ['??']."
"
} ?
}else{ //??? ?? ???? ??? ?? ?? ??? ? ????
///////////////////////////////////////////////// //// /////////////////////
echo $citysResult['error_code'].":".$citysResult['reason']
} 2. ??/ID? ???? ???? ????
?? ?? ?? ?? ID? ?? ????? ?????. ?? ID? ?? ?? ??? ??? ?? ID???.
$cityWeatherResult = $weather->getWeather('Suzhou'); >
if($cityWeatherResult['error_code'] == 0){ //??? ?? ???? ??? ?? ?? ??? ? ????
///////////////////////////////////////////////// //// /////////////////////
$data = $cityWeatherResult['??']
echo "========?? ??=======
";
echo "??: ".$data['sk']['temp']." "
echo "??: ".$data['sk']['wind_direction']." (".$data['sk']['wind_strength'].")"
echo "??:".$data['sk']['??']." "
echo "
";
echo "========??? ?? ??? ????=======
";
foreach($data['future'] as $wkey =>$f){
echo "??:".$f['date']." ".$f['week']." ".$f['weather']." ".$f['temp']."< br>";
} ?
echo "
";
echo "========?? ?? ??=======
";
echo "??? ??: ".$data['today']['dressing_index']." , ".$data['today']['dressing_advice']."
";echo "UV ??:".$data['today']['uv_index']."
"
echo "??? ??:".$data['today']['comfort_index']."
"
echo "?? ??:".$data['today']['wash_index']
echo "
";
}???{
echo $cityWeatherRe
3. ???? IP ??? ???? ?? ????? ?????
???? ??? ?? ????? ???? IP ??? ?? ?????. IP ?? ??? ??? ?? ? ????, ??? ??? ??? ???? ?? ??? ?? ?? ????.
$ipWeatherResult = $weather->getWeatherByIP('58.215.154.128') $ipWeatherResult?=?$weather->getWeatherByIP('58.215.154.128');??<br>
if($ipWeatherResult['error_code']?==?0){????//以下可根據(jù)實際業(yè)務(wù)需求,自行改寫??<br>
????//////////////////////////////////////////////////////////////////////??<br>
????$data?=?$ipWeatherResult['result'];??<br>
????echo?"=======當(dāng)前城市=======<br>";??<br>
????echo?$data['today']['city'];??<br>
????echo?"<br><br>";??<br>
????echo?"=======當(dāng)前天氣實況=======<br>";??<br>
????echo?"溫度:".$data['sk']['temp']."????";??<br>
????echo?"風(fēng)向:".$data['sk']['wind_direction']."????(".$data['sk']['wind_strength'].")";??<br>
????echo?"濕度:".$data['sk']['humidity']."????";??<br>
????echo?"<br><br>";??<br>
??<br>
????echo?"=======未來幾天天氣預(yù)報=======<br>";??<br>
????foreach($data['future']?as?$wkey?=>$f){??<br>
????????echo?"日期:".$f['date']."?".$f['week']."?".$f['weather']."?".$f['temperature']."<br>";??<br>
????}??<br>
????echo?"<br><br>";??<br>
??<br>
????echo?"=======相關(guān)天氣指數(shù)=======<br>";??<br>
????echo?"穿衣指數(shù):".$data['today']['dressing_index']."?,?".$data['today']['dressing_advice']."<br>";??<br>
????echo?"紫外線強度:".$data['today']['uv_index']."<br>";??<br>
????echo?"舒適指數(shù):".$data['today']['comfort_index']."<br>";??<br>
????echo?"洗車指數(shù):".$data['today']['wash_index'];??<br>
????echo?"<br><br>";??<br>
??<br>
}else{??<br>
????echo?$ipWeatherResult['error_code'].":".$ipWeatherResult['reason'];??<br>
}?
if($ipWeatherResult['error_code'] == 0){ //??? ?? ???? ??? ?? ?? ??? ? ????
///////////////////////////////////////////////// /// /////////////////////
$data = $ipWeatherResult['??'] <br>
echo "========?? ??=======<br>";
echo $data['??']['??'];
echo "<br><br>";
echo "========?? ??=======<br>";
echo "??: ".$data['sk']['temp']." " <br>
echo "??: ".$data['sk']['wind_direction']." (".$data['sk']['wind_strength'].")" <br>
echo "??: ".$data['sk']['??']." "
echo "<br><br>";
echo "=======??? ?? ??? ????=======<br>";
foreach($data['future'] as $wkey =>$f){
echo "??:".$f['date']." ".$f['week']." ".$f['weather']." ".$f['temp']."< br>";
} ?
echo "<br><br>";
echo "========?? ?? ??=======<br>";
echo "??? ??: ".$data['today']['dressing_index']." , ".$data['today']['dressing_advice']."<br>";
echo "UV ??:".$data['today']['uv_index']."<br>"
echo "??? ??:".$data['today']['comfort_index']."<br>"
echo "?? ??:".$data['today']['wash_index']
echo "<br><br>";
}???{
echo $ipWeatherResult['error_code'].":".$ipWeatherResult['reason'];
} 4. GPS ??? ???? ?? ??? ??? ?????
2, 3, 4? ?? ?? ????? ???? ?? ??? ???? ?? ??? ?? ??? ????? ???? ??? ?? ???? ????? ???? ??? ????. $geoWeatherResult = $weather->getWeatherByGeo(116.401394,39.916042)
if($geoWeatherResult['error_code'] == 0){ //??? ?? ???? ??? ?? ?? ??? ? ????
///////////////////////////////////////////////// /// ///////////////////// $data = $geoWeatherResult['??'] <br>
echo "========?? ??=======<br>";
echo $data['??']['??'];
echo "<br><br>";
echo "========?? ??=======<br>";
echo "??: ".$data['sk']['temp']." " <br>
echo "??: ".$data['sk']['wind_direction']." (".$data['sk']['wind_strength'].")" <br>
echo "??: ".$data['sk']['??']." " <br>
echo "<br><br>";
<br>
echo "=======??? ?? ??? ????=======<br>";
foreach($data['future'] as $wkey =>$f){ <br>
echo "??:".$f['date']." ".$f['week']." ".$f['weather']." ".$f['temp']."< br>"; <br>
} ?<br>
echo "<br><br>";
<br>
echo "========?? ?? ??=======<br>";
echo "??? ??: ".$data['today']['dressing_index']." , ".$data['today']['dressing_advice']."<br>";
echo "UV ??:".$data['today']['uv_index']."<br>" <br>
echo "??? ??:".$data['today']['comfort_index']."<br>" <br>
echo "?? ??:".$data['today']['wash_index'] <br>
echo "<br><br>";
<br>
}???{ <br>
echo $geoWeatherResult['error_code'].":".$geoWeatherResult['reason'] <br>
} <br>5. 3?? ?? ?? ??? ????? <br>
3???? ?? ??? ?? ?????. <br>$forecastResult = $weather->getForecast("Suzhou") <br>
if($forecastResult['error_code'] == 0){ //??? ?? ???? ??? ?? ?? ??? ? ???? <br>
///////////////////////////////////////////////// /// ///////////////////// <br>
$data = $forecastResult['??'] <br>
foreach($data as $key => $d){ <br>
echo "??:".$d['date']." (".$d['sh']."point-".$d['eh']."point) ".$d['weather' ]." ".$d['temp1']."~".$d["temp2"]."<br>" <br>
} ?<br>
}else{ //??? ?? ???? ??? ?? ?? ??? ? ????
///////////////////////////////////////////////// /// /////////////////////
echo $forecastResult['error_code'].":".$forecastResult['reason'] $forecastResult?=?$weather->getForecast("蘇州");??<br>
if($forecastResult['error_code']?==?0){????//以下可根據(jù)實際業(yè)務(wù)需求,自行改寫??<br>
????//////////////////////////////////////////////////////////////////////??<br>
????$data?=?$forecastResult['result'];??<br>
????foreach($data?as?$key?=>?$d){??<br>
????????echo?"日期:".$d['date']."?(".$d['sh']."點-".$d['eh']."點)??".$d['weather']."?".$d['temp1']."~".$d["temp2"]."<br>";??<br>
????}??<br>
}else{????//以下可根據(jù)實際業(yè)務(wù)需求,自行改寫??<br>
????//////////////////////////////////////////////////////////////////////??<br>
????echo?$forecastResult['error_code'].":".$forecastResult['reason'];??<br>
}??
}
?? ?? ??? ?? ?? ??? ?? ??? ???? API? ???? ??? ?? ???? ??? ?? ? ????.
????? class.juhe.weather.php? ?? ??? ?????: <br><!--?php <br />
// +---------------------------------- --- ---------- <br />
// | JuhePHP [ NO ZUO NO DIE ] <br />
// +---------------------------------- --- ---------- <??>// | Copyright (c) 2010-2015 http://juhe.cn <br />
// +---------------------------------- --- ---------- <br />
// | ???: Juhedata <info@juhe.cn-->
// +---------------------------------- --- ---------- <br>
<br>
//----------------------------------- <br>
// ??? ??? ???? ????? ?? ??? <br>
//----------------------------------- <br>
?? ??{ <br>
Private $appkey = false // ???? ?? APPKEY ?? <br>
<br>
Private $cityUrl = 'http://v.juhe.cn/weather/citys'; //?? ?? API URL <br>
<br>
Private $weatherUrl = 'http://v.juhe.cn/weather/index'; //??? ?? API URL ?? <br>
<br>
Private $weatherIPUrl = 'http://v.juhe.cn/weather/ip'; //IP ?? ?? ?? API URL ?? <br>
<br>
Private $weatherGeoUrl = 'http://v.juhe.cn/weather/geo'; //GPS ??? ???? ?? API URL ???? <br>
<br>
Private $forecast3hUrl = 'http://v.juhe.cn/weather/forecast3h'; //?? ?? 3?? ?? API URL ???? <br>
<br>
?? ?? __construct($appkey){ <br>
????????? $this->appkey = $appkey;????????????????????????????????
} ?<br>
<br>
/**<br>
* ???? ?? ?? ?? ?? <br>
* @return ?? <br>
??*/ <br>
?? ?? getCitys(){ <br>
$params = 'key='.$this->appkey <br>
$content = $this->juhecurl($this->cityUrl,$params) <br>
????????? return $this->_returnArray($content); <br>
} ?<br>
<br>
/**<br>
* ?? ??/ID? ???? ??? ?? ??? ????? <br>
* @param string $city [?? ??/ID] <br>
* @return ?? <br>
??*/ <br>
?? ?? getWeather($city){ <br>
???????? $paramsArray = ??(?<br>
??????????? '?'???? =>
'?? ??' => $??, <br>
> >? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
); <br>
???????? $params = http_build_query($paramsArray); <br>
???????? $content = $this->juhecurl($this->weatherUrl,$params); <br>
????????? return $this->_returnArray($content); <br>
} ?<br>
<br>
/**<br>
* IP ??? ???? ?? ?? ??? ????? <br>
* @param string $ip [IP ??] <br>
* @return ?? <br>
??*/ <br>
?? ?? getWeatherByIP($ip){ <br>
????????? $paramsArray = ??(?<br>
'?' => $this->appkey, <br>????????????'ip'??=>?$ip,??<br>
????????????'??'????=>?2??<br>
????????);??<br>
????????$params?=?http_build_query($paramsArray);??<br>
????????$content?=?$this->juhecurl($this->weatherIPUrl,$params);??<br>
????????return $this->_returnArray($content);??<br>
????}??<br>
??<br>
????/**<br>
* GPS ??? ???? ?? ????? ????? <br>
* @param string $lon [??] <br>
* @param string $lat [??] <br>
* @return ?? <br>
??*/??<br>
?????? ?? getWeatherByGeo($lon,$lat){??<br>
????????$paramsArray?=???(??<br>
????????????'?'???=>?$this->appkey,??<br>
????????????'?'??=>?$lon,??<br>
????????????'??'???=>?$lat,??<br>
????????????'??'????=>?2??<br>
????????);??<br>
????????$params?=?http_build_query($paramsArray);??<br>
????????$content?=?$this->juhecurl($this->weatherGeoUrl,$params);??<br>
????????return $this->_returnArray($content);??<br>
????}??<br>
??<br>
????/**<br>
* 3?? ?? ??? ????? <br>
* @param string $city [?? ??] <br>
* @return ?? <br>
??*/??<br>
?????? ?? getForecast($city){??<br>
????????$paramsArray?=???(??<br>
????????????'?'???=>?$this->appkey,??<br>
????????????'?? ??'??=>?$??,??<br>
????????????'??'????=>?2??<br>
????????);??<br>
????????$params?=?http_build_query($paramsArray);??<br>
????????$content?=?$this->juhecurl($this->forecast3hUrl,$params);??<br>
????????return $this->_returnArray($content);??<br>
????}??<br>
??<br>
????/**<br>
* JSON ??? ???? ???? ?? <br>
* @param string $content [??] <br>
* @return ?? <br>
??*/??<br>
?????? ?? _returnArray($content){??<br>
????????json_decode($content,true)? ?????.??<br>
????}??<br>
??<br>
????/**?<br>
?????*?請求接口返回內(nèi)容?<br>
?????*?@param??string?$url?[請求的URL地址]?<br>
?????* @param ??? $params[請求的參數(shù)]<br>?????* @param??int?$ipost?[是否采用POST?式]?<br>
?????*?@return??????<br>
?????*/??<br>
?????? ?? juhecurl($url,$params=false,$ispost=0){??<br>
????????$httpInfo?=???();??<br>
????????$ch?=?curl_init();??<br>
??<br>
?????????_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);??<br>
????????cur_setopt($ch, CURLOPT_USERAGENT,?'Mozilla/5.0(Windows NT 10.0; WOW64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');??<br>
?????????_setopt(?$ch,?CURLOPT_CONNECTTIMEOUT?,?30?);??<br>
?????????_setopt(?$ch,?CURLOPT_TIMEOUT?,?30);??<br>
????????cur_setopt(?$ch,?CURLOPT_RETURNTRANSFER?,?true?);??<br>
????????if(?$ispost?)??<br>
????????{??<br>
????????????cur_setopt(?$ch?,?CURLOPT_POST?,?true?);??<br>
?????????????_setopt(?$ch?,?CURLOPT_POSTFIELDS?,?$params?);??<br>
?????????????_setopt(?$ch?,?CURLOPT_URL?,?$url?);??<br>
????????}??<br>
??????????? ?????<br>
????????{??<br>
????????????if($params){??<br>
????????????????cur_setopt(?$ch?,?CURLOPT_URL?,?$url.'?'.$params?);??<br>
????????????}else{??<br>
?????????????????_setopt(?$ch?,?CURLOPT_URL?,?$url);??<br>
????????????}??<br>
????????}??<br>
????????$???=?curl_exec(?$ch?);??<br>
????????if?($response?===?FALSE)?{??<br>
????????????//???"cURL???:?"?.??_??($ch);??<br>
????????????false? ?????.??<br>
????????}??<br>
????????$httpCode?=?curl_getinfo(?$ch?,?CURLINFO_HTTP_CODE?);??<br>
????????$httpInfo?=?array_merge(?$httpInfo?,?curl_getinfo(?$ch?)?);??<br>
?????????_??(?$ch?);??<br>
????????$??? ?????.??<br>
????}??<br>
??<br>
}??

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











"Go ?? ????? ??: ? ??? ?? ??" ???? ??? ??? ?? ? ??? ??? ???? ???? ? ? ??? ?????. ??? ??? ??? ??? ?? ????? ??? Go ??? ? ?? ????? ???? ?? ???? ????. ? ????? ?? ?? ??? ?? ? ??? Go ??? ???? ??? ????? ??? Go ??? ? ? ???? ???? ??? ? ??????? ??? ? ????. 1. ??? HTTP ?? ?? ??? ?????.

Huawei ???? ?? ??? ?? ?? ???: ?????? ???? ???? ?? Java ?? ?? IoT ??? ??? ??? ?? ???? ???? ?? ? ?? ??? ?? ??? ??????? ??? ?? ??????. Huawei Cloud? ?? ??? ???? ???? ??? ?? ???? ??? ???? ??? ?? ??? ???? ?? ??? ??????? ?? ?? ????? ? ??? ???. ? ????? Java ??? ?? Huawei Cloud ?? ??? ?????? ??? ???? ??? ?????. ?? ?? ??? ???? ???. Java Development Kit? ???? ??? ??????(

PHP? ???? ?? ?? ????? ?? ?? ?? ??? ???? ?? ?? ??? ?? ???? ???? ?? ?????. ??? ?? ?? ??? ?? ?? ?? ??? ?? ?????. ??? ???? ???? ?????? ??? ?? ?? ?? ?? ??? ????, ?? ??? ?????, ?? ???? ???? ? ????. ? ????? PHP? ???? ?? ?? ?? ??? ?? ??? ???? ??? ???? ?? ?? ??? ?????. 1. ?? ?? ?? ??? ?? ?? ??? ???? ?? ??????? ??????.

?? ?? ??? ?? Python ?????? ?? ?????. Python? ??? ??? ??? ????? ?????. ???? ?? Python ?????? ?? ?? ??? ???? ?? ?? ?????. ? ????? ??? ???? ? ??? ?? ? ?? ???? ?? ??? ?????. Print HelloWorldprint("HelloWorld") ??? Python?? ?? ??? ?? ?????. print() ??? ??? ??? ???? ? ?????.

Java ?? ??? ?? ??? ?? ?? ?? ??? ??? ??? ??? ??? ?? ??? ??? ??? ???? ??? ????? ???? ???? ?? ???????. ??? ?? ??? ???? ??? ???? ??? Java ?? ?????. publicclassBubbleSort{publicstaticvoidbubbleSort(int[]arr){int

PHP ??? ???? ??? ?? ?? ???? ?? ? ??? ? ??????? ???? ? ?????. ? ????? PHP ??? ????? ???? 10?? ?? ??? ?? ??? ???? ??? ?????. 1. ??? ?? ?? $username=$_POST["username"];$passWord=$_POST["password"] ? ???? ?? ???? ??? ??? ????? ???? ?? ??? ?? ??? ?????. 2. ?? ? $database_host="localhost";$database_username="username";$database_pa? ?????.

??: ????? ????: Go ???? ????? ???? ??? ??? ?? ?? ??? ??? ??????? ??? ??? ?? ?????? ?????. Go ???? ????? ???? ??? ??? ?? ??? ??? ??? ??? ??? ????? ?? ?? ?????? ?? ? ?????. ? ????? Go ???? ????? ???? ??? ??? ???? ??? ??? ??? ??? ????? ? ??? ?? ?? ?? ??? ?????. 1. ??(Array) ??? ?? ?????, ?? ??? ??

Java ?? ?? ?? ?? ?? ??? ? ?? ?? ??? ???? ?? ?? ??? ?? ??(?? ?? ?) ??? ?? ???? ?? ??? ??? ??? ???? ???? ???? ?? ???????. ? ????? ?? ??? ?? ?? ?? ???? ???? ?? Java ?? ??? ?????. ???? ?? ?? ??? ?? ??? ??? ??? ??? ??? ???? ?? ??? ? ???? ??? ????. ?? ???? ?? ???? ?? ??(?? ?? ?) ??? ???? ??? ??? ?? ?????. ?? ??? ?????.
