I have the following code that works in test regions that do not use SSL, but not on the production system, which does. The call itself works in the browser, but when I start via cURL, I get an error of 500.
$region = "https://api.mysite.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . "/cacert.pem");
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_URL, $region . $api);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$resp = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
return $resp;
If I do not put CURL_OPT_FAILONERROR, then I get no error, just an empty answer. I am sure that this is due to the fact that this happens via https (since this is the only difference between my test region and my current region), but I cannot figure out how to make this work.
source
share