|
@@ -28,6 +28,14 @@ class Dingtoken extends Base
|
|
|
**/
|
|
|
public function main()
|
|
|
{
|
|
|
+ $options = \think\Config::get('redis');
|
|
|
+ $redis = new Redis($options);
|
|
|
+ $key = 'dingtalk_access_token';
|
|
|
+ $access_token_data = $redis->get($key);
|
|
|
+ if ($access_token_data) {
|
|
|
+ return json_decode($access_token_data, true);
|
|
|
+ }
|
|
|
+
|
|
|
$client = self::createClient();
|
|
|
$getAccessTokenRequest = new GetAccessTokenRequest([
|
|
|
"appKey" => "dingekepwoyycxfbtyvg",
|
|
@@ -45,6 +53,13 @@ class Dingtoken extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return $res;
|
|
|
+ if($res->body){
|
|
|
+ $data = [
|
|
|
+ 'accessToken'=>$res->body->accessToken,
|
|
|
+ 'expireIn'=>$res->body->expireIn,
|
|
|
+ ];
|
|
|
+ $redis->set($key, json_encode($data), 7000);
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|
|
|
}
|