Reputation: 6147
I have a curl request, it working fine in my localhost, I have uploaded it to server but it hangs and end with error 500 internal server error. If remove the line echo $output = curl_exec($ch);
It works fine.
$url = "https://someserver.com/api/";
$username = "some_user";
$password = "some_apss";
if(!extension_loaded('curl')){
die("Curl extension not loaded");
}
if(!function_exists('curl_init')){
die("curl_init not found");
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
echo $output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);`
Upvotes: 0
Views: 2100
Reputation: 6147
That was the issue with my server port. That port was closed. After opening the port its working perfect. Thank you all
Upvotes: 0
Reputation: 3412
It maybe that the curl extension installed on the server with the script isn't compiled with ssl support. Execute the folowing code on the server and post back the results:
<?php
$version = curl_version();
$ssl_supported= ($version['features'] & CURL_VERSION_SSL);
echo $ssl_supported == CURL_VERSION_SSL;
it should output 1. if not you have to install the ssl suport for curl
Upvotes: 0