0

I am using cloudflare's API to manage my website and it's documentation says this-

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records" \
 -H "X-Auth-Email: user@example.com" \
 -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
 -H "Content-Type: application/json" \
 --data '{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}'

And the PHP code i have tried is this -

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.cloudflare.com/client/v4/zones/92g6wwa3794g8wsf040s9t12a511a3/dns_records");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"type":"A","name":"example.com","content":"127.0.0.1","ttl":120,"proxied":false}');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Auth-Email: email@mail.com',
'X-Auth-Key: bf1f67fdjbdkhwois56465813fcdb7',
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
echo $server_output;
?>

It is working on Actual hosting but not working on localhost. But i am getting empty result, What i am doing wrong in this?

  • 1
    What does `curl_error` give you? http://php.net/manual/en/function.curl-error.php – fubar Aug 11 '17 at 02:37
  • it gives me this - "SSL certificate problem: unable to get local issuer certificate".@fubar – Devanshu Goyal Aug 11 '17 at 02:40
  • https://stackoverflow.com/questions/24611640/curl-60-ssl-certificate-unable-to-get-local-issuer-certificate || will this help.. – Devanshu Goyal Aug 11 '17 at 02:45
  • @fubar it is still displaying same problem – Devanshu Goyal Aug 11 '17 at 02:50
  • Sorry, I just re-read and it sad local. It looks like there are lots of similar issues on SO. I'd suggest you look at the solved questions for that error, as that's all I'd be doing to help you further. – fubar Aug 11 '17 at 02:53
  • most likely its an old, fixed bug with OpenSSL. upgrade your curl & openssl dlls, and the ssl error should go away. i've seen that error countless times with the solution being to update libcurl & openssl – hanshenrik Sep 24 '17 at 13:03

0 Answers0