|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
namespace app\admin\common;
|
|
|
+use think\facade\Cache;
|
|
|
use Youzan\Open\Client;
|
|
|
use Youzan\Open\Token;
|
|
|
|
|
@@ -13,6 +14,7 @@ class YouZan
|
|
|
private $clientSecret='3c654aa2fbc1b5da788ffdba45fb96f0';
|
|
|
private $method='https://open.youzanyun.com/api/';
|
|
|
private $apiVersion='3.0.0';
|
|
|
+ private $authorityId='109334129';
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->Token =new Token($this->clientId,$this->clientSecret);
|
|
@@ -20,10 +22,16 @@ class YouZan
|
|
|
}
|
|
|
|
|
|
public function GetData($method,$params=[]){
|
|
|
- return $this->Client->post($this->method.$method,$this->apiVersion, $params);
|
|
|
+ return $this->Client->post($method,$this->apiVersion, $params);
|
|
|
}
|
|
|
private function GetToken(){
|
|
|
- return $this->Token->getSelfAppToken("silent",["refresh"=>true]);
|
|
|
+ $token = Cache::get("YouZanToken");
|
|
|
+ if(isset($token)&& $token!=""){
|
|
|
+ return $token['access_token'];
|
|
|
+ }
|
|
|
+ $token =$this->Token->getSelfAppToken($this->authorityId,["refresh"=>true]);
|
|
|
+ Cache::set("YouZanToken",$token,3500);
|
|
|
+ return $token['access_token'];
|
|
|
}
|
|
|
|
|
|
|