![](/img/trans.png)
[英]php - HTTP/1.1 500 Internal Server Error on file_get_contents
[英]PHP readfile() returns 'HTTP/1.1 500 Internal Server Error'
有一個奇怪的問題。 有一些肥皂api: https : //ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2
它可以在瀏覽器中正常工作
我試圖
readfile('https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2');
然后我得到HTTP / 1.1 500。
但是curl也可以正常工作:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2',
));
$resp = curl_exec($curl);
curl_close($curl);
echo $resp;
問:您如何看待,我可以通過readfile()從該api獲取HTTP 200? file_get_contents()也返回500錯誤。
ps:為什么要使用readfile(),但不能使用SoapClient:據我所知,SoapClient類將readfile()封裝在其中。 因此,如果我從readfile()獲得成功,那么我將嘗試為SoapClient找到解決方案。
如果我在瀏覽器中打開https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2 ,它確實會給我一個HTTP 500錯誤(請檢查開發人員工具中的“網絡”標簽)。
我得到的結果是這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>Policy Falsified</faultstring>
<faultactor>https://ctaau.vedaxml.com:8443/cta/sys2/business-enquiry-v3-2</faultactor>
<detail>
<l7:policyResult
status="Service Not Found. The request may have been sent to an invalid URL, or intended for an unsupported operation." xmlns:l7="http://www.layer7tech.com/ws/policy/fault"/>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
查看結果狀態消息
無法提供服務。 該請求可能已發送到無效的URL,或打算用於不受支持的操作。
查找有關API的文檔,找到正確的服務URL或找出是否需要在使用API之前先進行身份驗證。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.