我正在使用json_decode
函數來解析使用php的json格式。 它第一次工作。 所以在這裏,你可以看到代碼:503服務在php中使用json解碼不可用
$login = 'username';
$password = 'password';
$url = "webServiceLink";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
$json_arr = json_decode($result, true);
但是,當我把代碼放到PHP函數,我得到以下錯誤:
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
檢查您的服務器日誌中是否有PHP錯誤。 – Barmar
假設「webServiceLink」實際上是一個遠程URL,並且503將來自該服務,除非您控制該遠程服務,否則您運氣不佳 – Phil