作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

个人中心接口设计

@@ -16,17 +16,10 @@ use app\portal\service\ToolsService; @@ -16,17 +16,10 @@ use app\portal\service\ToolsService;
16 16
17 class AdminPostController extends AdminBaseController 17 class AdminPostController extends AdminBaseController
18 { 18 {
19 - protected $appid;  
20 - protected $app_secret;  
21 - public function __construct()  
22 - {  
23 - $this->appid = config('app_id');  
24 - $this->app_secret = config('app_secret');  
25 - }  
26 19
27 public function getAccessToken() 20 public function getAccessToken()
28 { 21 {
29 - $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $this->appid . '&secret=' . $this->app_secret; 22 + $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . config('app_id') . '&secret=' . config('app_secret');
30 $html = file_get_contents($url); 23 $html = file_get_contents($url);
31 $output = json_decode($html, true); 24 $output = json_decode($html, true);
32 $access_token = $output['access_token']; 25 $access_token = $output['access_token'];