Skip to content

Commit f71c302

Browse files
committed
- 优化淘宝服务协议
1 parent bd826f4 commit f71c302

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v6.0.125 / 2020-11-19
2+
- 优化淘宝服务协议
3+
14
## v6.0.124 / 2020-11-19
25
- 小范围测试淘宝官方SDK
36

src/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* 定义当前版本
2727
*/
28-
const VERSION = '6.0.124';
28+
const VERSION = '6.0.125';
2929

3030
if (!function_exists('get_ip_info')) {
3131
/**

src/service/taobao/TbkService.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ class TbkService extends Service
8080
*/
8181
private $output;
8282

83+
/**
84+
* 安全协议
85+
* @var string
86+
*/
87+
private $protocol = 'http';
88+
89+
/**
90+
* 设置安全协议
91+
* @param string $protocol
92+
* @return $this
93+
*/
94+
public function setProtocol($protocol = 'http'): self
95+
{
96+
$this->protocol = $protocol;
97+
return $this;
98+
}
99+
83100
/**
84101
* 是否为沙箱
85102
* @return $this
@@ -927,10 +944,19 @@ private function http(): void
927944
$strParam = $this->createStrParam();
928945
$strParam .= 'sign=' . $sign;
929946
//访问服务
930-
if (empty($this->sandbox)) {
931-
$url = 'http://gw.api.taobao.com/router/rest?' . $strParam;
932-
} else {
933-
$url = 'http://gw.api.tbsandbox.com/router/rest?' . $strParam;
947+
if ($this->protocol === 'http') {
948+
if (empty($this->sandbox)) {
949+
$url = 'http://gw.api.taobao.com/router/rest?' . $strParam;
950+
} else {
951+
$url = 'http://gw.api.tbsandbox.com/router/rest?' . $strParam;
952+
}
953+
}
954+
if ($this->protocol === 'https') {
955+
if (empty($this->sandbox)) {
956+
$url = 'https://eco.taobao.com/router/rest?' . $strParam;
957+
} else {
958+
$url = 'https://gw.api.tbsandbox.com/router/rest?' . $strParam;
959+
}
934960
}
935961
$result = file_get_contents($url);
936962
$result = json_decode($result, true);

0 commit comments

Comments
 (0)