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?