我试图在一个特定的端口号:8999上向其余web服务添加信息。在本地主机上,它工作正常,但在实时服务器上,它给出以下错误:
cURL错误(28):connect()超时!
代码
$ch = curl_init('http://int.otono-me.com:8999/api/customers/new');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_PORT, 8999);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"X-Auth-Token: " . $_SESSION["Token"]
));
$result = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
if($curl_errno > 0) {
echo "cURL Error ($curl_errno): $curl_error'n";
} else {
echo "Successful'n";
}
curl_close($ch);
echo $result;
对于需要做什么有什么建议吗? 您在活动系统上有一个代理,或者在两者之间设置防火墙
向您的本地系统询问有关防火墙的更改。
您还缺少一个'
:
$ch = curl_init('http://int.otono-me.com:8999/api/customers/new');
// -------^
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://int.otono-me.com:8999/api/customers/new");
你的链接也没有应答
不要在URL中实现PORT。单独发送URL和PORT:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://int.otono-me.com/api/customers/new");
curl_setopt($ch, CURLOPT_PORT, 8999);