饮歌长啸
$client = new Aws\CloudFront\CloudFrontClient([ 'region' => 'us-east-1', 'version' => 'latest', 'credentials' => [ 'key' => $this->AcmKey, 'secret' => $this->AcmSecret ] ]); // $id = 'E2SYUN95DWJFXC'; $id = $business_custom_data->distribution_id; try { $result = $client->getDistribution([ 'Id' => $id, ]); } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; } $currentConfig = $result["Distribution"]["DistributionConfig"]; $ETag = $result["ETag"]; $distribution = [ 'CallerReference' => $currentConfig["CallerReference"], // REQUIRED 'Comment' => $currentConfig["Comment"], // REQUIRED 'DefaultCacheBehavior' => $currentConfig["DefaultCacheBehavior"], // REQUIRED 'DefaultRootObject' => $currentConfig["DefaultRootObject"], //'Enabled' => $currentConfig["Enabled"], // REQUIRED 'Enabled' => False, // REQUIRED 'Origins' => $currentConfig["Origins"], // REQUIRED 'Aliases' => $currentConfig["Aliases"], 'CustomErrorResponses' => $currentConfig["CustomErrorResponses"], 'HttpVersion' => $currentConfig["HttpVersion"], 'CacheBehaviors' => $currentConfig["CacheBehaviors"], 'Logging' => $currentConfig["Logging"], 'PriceClass' => $currentConfig["PriceClass"], 'Restrictions' => $currentConfig["Restrictions"], 'ViewerCertificate' => $currentConfig["ViewerCertificate"], 'WebACLId' => $currentConfig["WebACLId"], ]; try { $result = $client->updateDistribution([ 'DistributionConfig' => $distribution, 'Id' => $id, 'IfMatch' => $ETag ]); $status = true; //var_dump($result); //die; } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; }