|
|
|
@ -26,53 +26,54 @@
|
|
|
|
|
*
|
|
|
|
|
* Put the credentials in ~/.edgerc as demonstrated by api-kickstart/sample_edgerc
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Akamai\Open\Example;
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/cli/init.php';
|
|
|
|
|
|
|
|
|
|
class CcuClient
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var \Akamai\Open\EdgeGrid\Client
|
|
|
|
|
*/
|
|
|
|
|
protected $client;
|
|
|
|
|
/**
|
|
|
|
|
* @var \Akamai\Open\EdgeGrid\Client
|
|
|
|
|
*/
|
|
|
|
|
protected $client;
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('ccu');
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('ccu');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function postPurgeRequest($hostname, $objects)
|
|
|
|
|
{
|
|
|
|
|
$purge_body = [
|
|
|
|
|
'objects' => $objects
|
|
|
|
|
];
|
|
|
|
|
public function postPurgeRequest($hostname, $objects)
|
|
|
|
|
{
|
|
|
|
|
$purge_body = [
|
|
|
|
|
'objects' => $objects
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$response = $this->client->post('/ccu/v3/invalidate/url', [
|
|
|
|
|
'body' => json_encode($purge_body),
|
|
|
|
|
'headers' => ['Content-Type' => 'application/json']
|
|
|
|
|
]);
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
$response = $this->client->post('/ccu/v3/invalidate/url', [
|
|
|
|
|
'body' => json_encode($purge_body),
|
|
|
|
|
'headers' => ['Content-Type' => 'application/json']
|
|
|
|
|
]);
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ccu = new CcuClient();
|
|
|
|
|
$url = $_POST['url'];
|
|
|
|
|
|
|
|
|
|
echo $url;die();
|
|
|
|
|
try {
|
|
|
|
|
$objects = [
|
|
|
|
|
$url
|
|
|
|
|
];
|
|
|
|
|
$objects = [
|
|
|
|
|
$url
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$purge = $ccu->postPurgeRequest('data.chinarundreisen.com', $objects);
|
|
|
|
|
$response = json_decode($purge->getBody());
|
|
|
|
|
if($response->httpStatus == 201){
|
|
|
|
|
echo '{"msg":"success"}';
|
|
|
|
|
}else{
|
|
|
|
|
echo json_encode($response);
|
|
|
|
|
}
|
|
|
|
|
$purge = $ccu->postPurgeRequest('data.chinahighlights.com', $objects);
|
|
|
|
|
$response = json_decode($purge->getBody());
|
|
|
|
|
if ($response->httpStatus == 201) {
|
|
|
|
|
echo '{"msg":"success"}';
|
|
|
|
|
} else {
|
|
|
|
|
echo json_encode($response);
|
|
|
|
|
}
|
|
|
|
|
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
|
|
|
|
header("status: 404 not found");
|
|
|
|
|
echo "An error occurred: " .$e->getMessage(). "\n";
|
|
|
|
|
header("status: 404 not found");
|
|
|
|
|
echo "An error occurred: " . $e->getMessage() . "\n";
|
|
|
|
|
}
|
|
|
|
|