PHP Cloudflare Cache Silme

PHP Cloudflare Cache Silme

Aşağıdaki bilgileri kendinize göre düzenleyerek cloudflare cache silme işlemini yapabilirsiniz.

<?php

$authKey = "??";
$authEmail = "???";

$zoneId = "???";
$endpoint = "purge_cache";

$data = [
    "purge_everything" => true
];

$url = "https://api.cloudflare.com/client/v4/zones/{$zoneId}/{$endpoint}";
$opts = ['http' => [
    'method' => 'DELETE',
    'header' => [
        "Content-Type: application/json",
        "X-Auth-Key: {$authKey}",
        "X-Auth-Email: {$authEmail}",
    ],
    'content' => json_encode($data),
]];
$context = stream_context_create($opts);
echo $result = file_get_contents($url, false, $context);