Try to setting the port number like this:
curl_setopt($curl, CURLOPT_PORT, 8088);
where 8088 is your real port number.
Also the proper way of handling the SSL requests involves setting the CURLOPT_CAINFO
parameter:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_CAINFO, getcwd() . "/folder/your-secure-certificate.crt");
This ensures that not just any server certificate will be trusted by your cURL
session.
For example, if an attacker were to somehow redirect traffic from api.example.com
to their own server, the cURL
session here would not properly initialize, since the attacker would not have access to a server certificate (i.e. would not have the private key) trusted by the CA we added.
EDIT:
Many hosting companies don't allow connections "back" to your own host from your own PHP programs so perhaps that's what's happening here. Also try to apply the proxy settings, which is used in your LAN and see if it works, add this to your code if necessary:
$proxy = '127.0.0.1:8888';
curl_setopt($curl, CURLOPT_PROXY, $proxy);