Skip to content

Instantly share code, notes, and snippets.

@noeljackson
Created November 14, 2016 19:21
Show Gist options
  • Save noeljackson/5970dfed57ffd594f5e0b8542bbc7415 to your computer and use it in GitHub Desktop.
Save noeljackson/5970dfed57ffd594f5e0b8542bbc7415 to your computer and use it in GitHub Desktop.
<?php
$email = "[email protected]";
$apikey = yourkey;
$zoneid = yourzone;
$ch = curl_init( 'https://api.cloudflare.com/client/v4/zones/' . $zoneid . '/purge_cache' );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('purge_everything' => true)) );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'X-Auth-Email: ' . $email,
'X-Auth-Key: ' . $apikey
));
$result = curl_exec($ch);
if (curl_errno($ch) != 0) {
echo curl_errno($ch);
}
echo $result;
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment