方便测试,展示不用CDN加速

ct-mobile-first
ycc 5 years ago
parent 1541a2dd69
commit 66afd50df0

@ -18,7 +18,7 @@
* Note that in order for this to work you need to provision credentials * Note that in order for this to work you need to provision credentials
* specifically for CCU - you cannot extend existing credentials to add * specifically for CCU - you cannot extend existing credentials to add
* CCU as it's managed under "CCU" in the API credential system. * CCU as it's managed under "CCU" in the API credential system.
* *
* Configure->Organization->Manage APIs * Configure->Organization->Manage APIs
* Select "CCU APIs" * Select "CCU APIs"
* Create client collections/clients * Create client collections/clients
@ -26,53 +26,54 @@
* *
* Put the credentials in ~/.edgerc as demonstrated by api-kickstart/sample_edgerc * Put the credentials in ~/.edgerc as demonstrated by api-kickstart/sample_edgerc
*/ */
namespace Akamai\Open\Example; namespace Akamai\Open\Example;
require_once __DIR__ . '/cli/init.php'; require_once __DIR__ . '/cli/init.php';
class CcuClient class CcuClient
{ {
/** /**
* @var \Akamai\Open\EdgeGrid\Client * @var \Akamai\Open\EdgeGrid\Client
*/ */
protected $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) public function postPurgeRequest($hostname, $objects)
{ {
$purge_body = [ $purge_body = [
'objects' => $objects 'objects' => $objects
]; ];
$response = $this->client->post('/ccu/v3/invalidate/url', [ $response = $this->client->post('/ccu/v3/invalidate/url', [
'body' => json_encode($purge_body), 'body' => json_encode($purge_body),
'headers' => ['Content-Type' => 'application/json'] 'headers' => ['Content-Type' => 'application/json']
]); ]);
return $response; return $response;
} }
} }
$ccu = new CcuClient(); $ccu = new CcuClient();
$url = $_POST['url']; $url = $_POST['url'];
echo $url;die();
try { try {
$objects = [ $objects = [
$url $url
]; ];
$purge = $ccu->postPurgeRequest('data.chinarundreisen.com', $objects); $purge = $ccu->postPurgeRequest('data.chinahighlights.com', $objects);
$response = json_decode($purge->getBody()); $response = json_decode($purge->getBody());
if($response->httpStatus == 201){ if ($response->httpStatus == 201) {
echo '{"msg":"success"}'; echo '{"msg":"success"}';
}else{ } else {
echo json_encode($response); echo json_encode($response);
} }
} catch (\GuzzleHttp\Exception\ClientException $e) { } catch (\GuzzleHttp\Exception\ClientException $e) {
header("status: 404 not found"); header("status: 404 not found");
echo "An error occurred: " .$e->getMessage(). "\n"; echo "An error occurred: " . $e->getMessage() . "\n";
} }

@ -19,7 +19,7 @@
<link rel="dns-prefetch" href="//www.google-analytics.com"> <link rel="dns-prefetch" href="//www.google-analytics.com">
<link rel="dns-prefetch" href="//connect.facebook.net"> <link rel="dns-prefetch" href="//connect.facebook.net">
<link rel="dns-prefetch" href="//www.facebook.com"> <link rel="dns-prefetch" href="//www.facebook.com">
<link href="https://data.chinahighlights.com/css/mobile-first.css?v=123" rel="stylesheet"> <link href="https://proxy-data.chinahighlights.com/css/mobile-first.css?v=123" rel="stylesheet">
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

@ -8,7 +8,7 @@
<link rel="canonical" href="<!--@CANONICAL@-->"> <link rel="canonical" href="<!--@CANONICAL@-->">
<meta content="width=device-width,minimum-scale=1,initial-scale=1" name="viewport"> <meta content="width=device-width,minimum-scale=1,initial-scale=1" name="viewport">
<link rel="shortcut icon" href="//data.chinahighlights.com/favicon.ico"> <link rel="shortcut icon" href="//data.chinahighlights.com/favicon.ico">
<link href="https://data.chinahighlights.com/css/mobile-first.css?v=321" rel="stylesheet"> <link href="https://proxy-data.chinahighlights.com/css/mobile-first.css?v=321" rel="stylesheet">
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

Loading…
Cancel
Save