diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b4050f..eef2851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v6.0.125 / 2020-11-19 +- 优化淘宝服务协议 + ## v6.0.124 / 2020-11-19 - 小范围测试淘宝官方SDK diff --git a/src/common.php b/src/common.php index f9758f5..be6bc45 100644 --- a/src/common.php +++ b/src/common.php @@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService; /** * 定义当前版本 */ -const VERSION = '6.0.124'; +const VERSION = '6.0.125'; if (!function_exists('get_ip_info')) { /** diff --git a/src/service/taobao/TbkService.php b/src/service/taobao/TbkService.php index 2ba6644..1aa2919 100644 --- a/src/service/taobao/TbkService.php +++ b/src/service/taobao/TbkService.php @@ -80,6 +80,23 @@ class TbkService extends Service */ private $output; + /** + * 安全协议 + * @var string + */ + private $protocol = 'http'; + + /** + * 设置安全协议 + * @param string $protocol + * @return $this + */ + public function setProtocol($protocol = 'http'): self + { + $this->protocol = $protocol; + return $this; + } + /** * 是否为沙箱 * @return $this @@ -927,10 +944,19 @@ class TbkService extends Service $strParam = $this->createStrParam(); $strParam .= 'sign=' . $sign; //访问服务 - if (empty($this->sandbox)) { - $url = 'http://gw.api.taobao.com/router/rest?' . $strParam; - } else { - $url = 'http://gw.api.tbsandbox.com/router/rest?' . $strParam; + if ($this->protocol === 'http') { + if (empty($this->sandbox)) { + $url = 'http://gw.api.taobao.com/router/rest?' . $strParam; + } else { + $url = 'http://gw.api.tbsandbox.com/router/rest?' . $strParam; + } + } + if ($this->protocol === 'https') { + if (empty($this->sandbox)) { + $url = 'https://eco.taobao.com/router/rest?' . $strParam; + } else { + $url = 'https://gw.api.tbsandbox.com/router/rest?' . $strParam; + } } $result = file_get_contents($url); $result = json_decode($result, true);