dever 6 năm trước cách đây
mục cha
commit
02673da41e
2 tập tin đã thay đổi với 16 bổ sung0 xóa
  1. 1 0
      component/database/user.php
  2. 15 0
      component/src/Auth.php

+ 1 - 0
component/database/user.php

@@ -16,6 +16,7 @@ return array
 	# 显示给用户看的名称
 	'lang' => '用户管理',
 	'order' => 100,
+	'desc' => '请将component/auth.cron放到cron中,定时获取access token',
 	# 数据结构
 	'struct' => array
 	(

+ 15 - 0
component/src/Auth.php

@@ -73,6 +73,21 @@ class Auth
 		$this->wechat->login('component/auth.oauth');
 	}
 
+	/**
+     * 定期获取oauth的token 用户token
+     * 
+     * @return mixed
+     */
+    public function cron()
+    {
+        $user = Dever::db('component/user')->state();
+        if ($user) {
+        	foreach ($user as $k => $v) {
+        		$wechat->oauth($v['oauth_id'], 2000, true);
+        	}
+        }
+    }
+
 	/**
      * 获取oauth的token 用户token
      *