Purge File Returning Error
casbboy opened this issue · 3 comments
I'm certain I have the right variables in cloudflare_api(), as if I do:
$result = $api->get_zones();
var_dump($result);
This returns the zones and results for the account. So looks like api key and email are correct. But then I try:
$identifier = $api->identifier('mydomain.com');
$files = [
'http://cdn.mydomain.com/youtubeheader.jpg'
];
$result = $api->purge_files($identifier,$files);
var_dump($result);
It outputs this error:
["errors"]=>
array(2) {
[0]=>
object(stdClass)#3 (2) {
["code"]=>
int(7003)
["message"]=>
string(81) "Could not route to /zones/purge_cache, perhaps your object identifier is invalid?"
}
[1]=>
object(stdClass)#4 (2) {
["code"]=>
int(7000)
["message"]=>
string(21) "No route for that URI"
}
}
What am I doing wrong?
Cheers
Ryan
I think the identifier is not working. If I put this on my test page:
$result = $api->get_zones();
$identifier = $result->result[0]->id;
The above works. Maybe because I have two zones with Cloudflare?
This will get the identifier zone. But, doing
$identifier = $api->identifier('mydomain.com'); // this does not work
Seems the identifier function is bad
Made a solution without touching the included class file:
$result = $api->get_zones();
foreach($result->result as $item){
if($item->name=='yourdomain.com'){
$identifier = $item->id;
break;
}
}
That makes the correct identifier
Your correct it will be due to multiple zones, thanks for your solution i will tidy that up