cloudflare / cloudflare/cloudflare-php
Issues w/ creating Firewall rules
- Dominant language
- PHP
- Stars
- 674
- Forks
- 268
- PR merge metrics
- No merged PRs in 30d
Description
I keep getting a strange issue with this library and trying to create firewall rules. Some of the time, the code below works, but most of the time, I get a 400 bad request error with code "10202" filter at index 0.
I don't see where there are any issues with my expression and don't understand why this sometimes works but I get an error also with the same exact code being run.
```
require __DIR__ . '/vendor/autoload.php';
$key = new Cloudflare\API\Auth\APIKey('***', '***');
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$zones = new Cloudflare\API\Endpoints\Zones($adapter);
$fw = new Cloudflare\API\Endpoints\Firewall($adapter);
$sites = $zones->listZones('', '', 1, 300, '', '', 'all');
foreach ( $sites->result as $site ) :
$site_id = $site->id;
$site_name = $site->name;
$expression = 'ip.geoip.country ne {"US" "MX" "CA"}';
$config = new Cloudflare\API\Configurations\FirewallRuleOptions();
$config->setActionBlock();
$result = $fw->createFirewallRule(
$site_id,
$expression,
$config,
'Country Block'
);
endforeach;
```
Contributor guide
Assessment
This issue has not been assessed yet.