wugg 2 yıl önce
ebeveyn
işleme
d7e549798f
2 değiştirilmiş dosya ile 12 ekleme ve 4 silme
  1. 10 2
      app/admin/common/YouZan.php
  2. 2 2
      app/admin/controller/Login.php

+ 10 - 2
app/admin/common/YouZan.php

@@ -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'];
     }
 
 

+ 2 - 2
app/admin/controller/Login.php

@@ -23,8 +23,8 @@ class Login
             "keyword"=>"",
             "page_size"=>20
         ];
-
-        return $youzan->GetData("youzan.itemcategories.taglist.search",$params );
+        $data =$youzan->GetData("youzan.itemcategories.taglist.search",$params );
+        return  json_encode($data,JSON_UNESCAPED_UNICODE);
     }
 
     /**