0
下面的php代码正在进行一个返回json对象的REST API调用。这工作正常,当我在我的本地主机使用WAMP使用它绝对没有问题。PHP curl适用于本地主机,但不适用于Web服务器?
但是,当我推动这个应用程序在服务器上它会超时并显示503服务不可用。 我检查了它有一个条目的日志:
TimeOut Specified已过期。
我联系了我的管理员,他只是说这个应用程序监听PORT = 64665和HOST = 0.0.0.0。那是什么意思?我需要在代码中进行哪些更改以使其在服务器上工作?帮助
<?php
$url = "http://xyz.net/v2/plan/"; // I have changed the REST URI API Link for security reasons
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXY, false);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
// Will dump json
var_dump(json_decode($result, true));
$response = "http://xyz.net/v2/plan/";
echo $response;
?>
你有没有尝试设置端口,他说什么? 'curl_setopt($ ch,CURLOPT_PORT,64665);' – scragar
并且您是否检查过您使用的服务器是否将xyz.net解析为正确的IP地址? – l0ckm4
@scragar我试着设置curl_setopt($ ch,CURLOPT_PORT,64665);但它仍然不起作用 – user3398326