- 优化淘宝服务协议

v6 v6.0.125
李光春 4 years ago
parent bd826f48bc
commit f71c302c16

@ -1,3 +1,6 @@
## v6.0.125 / 2020-11-19
- 优化淘宝服务协议
## v6.0.124 / 2020-11-19 ## v6.0.124 / 2020-11-19
- 小范围测试淘宝官方SDK - 小范围测试淘宝官方SDK

@ -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')) { if (!function_exists('get_ip_info')) {
/** /**

@ -80,6 +80,23 @@ class TbkService extends Service
*/ */
private $output; 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 * @return $this
@ -927,10 +944,19 @@ class TbkService extends Service
$strParam = $this->createStrParam(); $strParam = $this->createStrParam();
$strParam .= 'sign=' . $sign; $strParam .= 'sign=' . $sign;
//访问服务 //访问服务
if (empty($this->sandbox)) { if ($this->protocol === 'http') {
$url = 'http://gw.api.taobao.com/router/rest?' . $strParam; if (empty($this->sandbox)) {
} else { $url = 'http://gw.api.taobao.com/router/rest?' . $strParam;
$url = 'http://gw.api.tbsandbox.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 = file_get_contents($url);
$result = json_decode($result, true); $result = json_decode($result, true);

Loading…
Cancel
Save