I'm trying to find solution for my problem and I found this post. I implement it and get this error
cURL Error: SSL certificate problem: self signed certificate
This is what I did saving the cacert.pem, I copy and paste it to notepad and put this to my path C:\xampp\htdocs\test and when I save it, it turns to cacert.pem.txt. I don't know if this is the right way to do it. The post said need a PATHTO(which folder cacert.pem save, I think). I put this to php.ini
curl.cainfo = "C:\xampp\htdocs\test\cacert.pem.txt"
and this is the code of my curl.
function curl_generator($url,$postData = array()){
if($url){
$data_string = json_encode($postData);
$ch = curl_init($url);
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt ($ch, CURLOPT_CAINFO, 'C:\xampp\htdocs\test\cacert.pem.txt');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
if ($result === FALSE) {
echo "cURL Error: " . curl_error($ch);
}
curl_close($ch);
return json_decode($result);
}else{
return false;
}
}
I don't know if this is the correct way. I'm now confuse and no idea of error.