php - Error when requesting an API Cloudflare. Why?
722
when I am run the following code:
<?php
$name = $_POST ["name"]; // its ZoneID
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/zones/$name/settings/ipv6');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"value\":\"off\"}");
$headers = array();
$headers[] = 'X-Auth-Email: MAIL';
$headers[] = 'X-Auth-Key: TOKEN';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
var_dump($result);
curl_close($ch);
?>
I get in response:
"{“success”:false,“errors”:[{“code”:7000,“message”:“No route for that URI”}],“messages”:[],“result”:null}"
$name I need to get from the form
Where is my mistake ?