curl php url工作正常,在服务器上没有响应

时间:2016-09-15 16:12:02

标签: php curl

我已经制作了一个小卷曲脚本,在localhost中运行时按预期工作,但是当我在服务器上运行时,我一直在连接超时......

endpoint_token = https://ngf.rhm.cloud:8244/token

$curl = curl_init($this->endpoint_token);
        curl_setopt($curl, CURLOPT_HEADER, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_HEADER,'Content-Type: application/json');
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        $postData = "";

        foreach($this->params as $k => $v)
        {
            $postData .= $k . '='.urlencode($v).'&';
        }

        $postData = rtrim($postData, '&');

        curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);


        $json_response = curl_exec($curl);

为什么它在预期的localhost中运行,但在我的服务器上什么都不做?

1 个答案:

答案 0 :(得分:1)

// Check for errors and display the error message
if($errno = curl_errno($curl)) {
    $error_message = curl_strerror($errno);
    echo "cURL error ({$errno}):\n {$error_message}";
}

尝试查看错误