signMethod = $signMethod ? $signMethod : ClientProfile::$SIGN_TC3_SHA256; $this->httpProfile = $httpProfile ? $httpProfile : new HttpProfile(); $this->unsignedPayload = false; $this->checkPHPVersion = true; $this->enableRegionBreaker = $enableRegionBreaker; $this->regionBreakerProfile = $regionBreakerProfile; //$this->language = ClientProfile::$ZH_CN; } /** * 设置签名算法 * @param string $signMethod 签名方法,目前支持SHA256,SHA1, TC3 */ public function setSignMethod($signMethod) { $this->signMethod = $signMethod; } /** * 设置http相关参数 * @param HttpProfile $httpProfile http相关参数 */ public function setHttpProfile($httpProfile) { $this->httpProfile = $httpProfile; } /** * 获取签名方法 * @return null|string 签名方法 */ public function getSignMethod() { return $this->signMethod; } /** * 设置是否忽略内容签名 * @param bool $flag true表示忽略签名 */ public function setUnsignedPayload($flag) { $this->unsignedPayload = $flag; } /** * 获取是否忽略内容签名标志位 * @return bool */ public function getUnsignedPayload() { return $this->unsignedPayload; } public function getCheckPHPVersion() { return $this->checkPHPVersion; } public function setCheckPHPVersion($flag) { $this->checkPHPVersion = $flag; } public function getLanguage() { return $this->language; } /** * @param string $language Valid values: zh-CN, en-US */ public function setLanguage($language) { $this->language = $language; } public function getRegionBreakerProfile() { return $this->regionBreakerProfile; } /** * 设置地域容灾相关参数 * @param RegionBreakerProfile $regionBreakerProfile 地域容灾相关参数 */ public function setRegionBreakerProfile($regionBreakerProfile) { $this->regionBreakerProfile = $regionBreakerProfile; } /** * 获取http选项实例 * @return null|HttpProfile http选项实例 */ public function getHttpProfile() { return $this->httpProfile; } } class RegionBreakerProfile { public function __construct($masterEndpoint, $slaveEndpoint, $maxFailNum = 5, $maxFailPercent = 0.75, $windowInterval = 60*5, $timeout = 60, $maxRequests = 5) { if (empty($masterEndpoint) || !(substr($masterEndpoint, -20) === '.tencentcloudapi.com')) { throw new TencentCloudSDKException("", 'masterEndpoint must be provided and end with ".tencentcloudapi.com"'); } if (empty($slaveEndpoint) || !(substr($slaveEndpoint, -20) === '.tencentcloudapi.com')) { throw new TencentCloudSDKException("", 'slaveEndpoint must be provided and end with ".tencentcloudapi.com"'); } $this->masterEndpoint = $masterEndpoint; $this->slaveEndpoint = $slaveEndpoint; $this->maxFailNum = $maxFailNum; $this->maxFailPercent = $maxFailPercent; if ($this->maxFailPercent < 0 || $this->maxFailPercent > 1) { throw new TencentCloudSDKException("", "ClientError: max fail percent must be set between 0 and 1"); } $this->windowInterval = $windowInterval; $this->timeout = $timeout; $this->maxRequests = $maxRequests; } }