Samples
Invalidation with PHP and CURL
<?php
/*
* WaveCDN API
* Invalidation sample
*/
// Parameters
$username = 'email@email.com';
$password = 'password';
$urls = array(
'http://domain.com/file1.png',
'http://domain.com/file2.png',
);
// Talk with api
$h = curl_init();
curl_setopt($h, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($h, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($h, CURLOPT_URL, 'https://api.wavecdn.com/v3/invalidation');
curl_setopt($h, CURLOPT_POSTFIELDS, 'urls='.implode('|', $urls));
curl_setopt($h, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($h);
$code = curl_getinfo($h, CURLINFO_HTTP_CODE);
curl_close($h);
// Evaluate result
if($code == 201)
{
echo "Success\n";
}
else if($code == 401)
{
echo "Authorization failed.\n";
exit(1);
}
else
{
echo "Invalidation was not successful:\n$response\n";
exit(1);
}
?>