PHP curl适用于localhost,但不适用于Web服务器?

时间:2014-07-10 13:21:45

标签: php rest curl

以下php代码正在进行REST API调用,返回json对象。当我使用WAMP在我的localhost上使用它时,这很好用。绝对没问题。

然而,当我在服务器上推送此应用程序时,它会显示TimeOut并显示503 Service Unavailable。 我检查了它有一个条目的日志:

  

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;
?>

1 个答案:

答案 0 :(得分:0)

检查服务器的/ etc / hosts文件,可能存在问题,即。域映射到另一个(错误的)IP地址。