php - Error when requesting an API Cloudflare. Why?
Get the solution ↓↓↓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 ?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function store() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.