I want to block an IP through API. I wrote this code:
<?php
$ip = '62.219.14.1';
require_once('vendor/autoload.php');
$key = new \Cloudflare\API\Auth\APIKey('[email protected]', 'MY_API_KEY');
$adapter = new Cloudflare\API\Adapter\Guzzle($key);
$Rules = new \Cloudflare\API\Endpoints\user\firewall\access_rules\rules('block', [
"target" => "ip",
"value" => $ip
],date('Y-m-d H:i', strtotime(time())));
But it doesn’t work and returns an error that \firewall\access_rules\rules class doesn’t exist in the library.
What’s wrong with it? How to block an IP?
Hi, thanks for your reply and attention.
It’s based on some examples I’ve found here:
There wasn’t any example about blocking an IP, so I’ve changed it’s examples to block an IP based on the parameters mentioned in documentation: https://api.cloudflare.com/
Can you give me an example about how to block an IP using this official Cloudflare library?