Created
January 19, 2018 22:45
-
-
Save sambshapiro/3647c6f08e0efa033bdd4670f704cc64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the script 💯