Skip to content

Instantly share code, notes, and snippets.

@sambshapiro
Created January 19, 2018 22:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sambshapiro/3647c6f08e0efa033bdd4670f704cc64 to your computer and use it in GitHub Desktop.
Save sambshapiro/3647c6f08e0efa033bdd4670f704cc64 to your computer and use it in GitHub Desktop.
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Client;
private function purgeImgixUrl($url) {
$client = new Client();
try {
$response = $client->post('https://api.imgix.com/v2/image/purger', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . base64_encode($this->ImgixApiToken . ':')
],
\GuzzleHttp\RequestOptions::JSON => ['url' => $url]
]);
}
catch (\Guzzle\Http\Exception\ClientErrorResponseException $exception) {
$responseBody = $exception->getResponse()->getBody(true);
echo $responseBody;
return false;
}
}
@arifulhb
Copy link

Thanks for the script 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment