Jeffrey
Jeffrey

Reputation: 135

curl php url works fine local, not responding on server

I've made a little curl script, works as expected while running it in localhost, but I keep getting connection timed-out when I run this on my server...

The 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);

Why is it functioning as expected localhost, but doing nothing on my server?

Upvotes: 2

Views: 728

Answers (1)

CatalinB
CatalinB

Reputation: 581

// 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}";
}

try to see for errors

Upvotes: 1

Related Questions