|
|
|
@ -63,8 +63,7 @@ class Server |
|
|
|
|
$result = $this->curlPost($url, json_encode($data), 10); |
|
|
|
|
$result = json_decode($result, true); |
|
|
|
|
if (!empty($result['component_access_token'])) { |
|
|
|
|
$expire = !empty($result['expires_in']) ? intval($result['expires_in']) : 7200; |
|
|
|
|
Cache::set('ComponentAccessToken', $result['component_access_token'], $expire); |
|
|
|
|
Cache::set('ComponentAccessToken', $result['component_access_token'], 6200); |
|
|
|
|
return $result['component_access_token']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -117,22 +116,18 @@ class Server |
|
|
|
|
*/ |
|
|
|
|
public function authorizationInfo($authorization_code) |
|
|
|
|
{ |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '回调进来了' . $authorization_code, 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=' . $this->getComponentAccessToken(); |
|
|
|
|
$data = []; |
|
|
|
|
$data['component_appid'] = self::APPID; |
|
|
|
|
$data['authorization_code'] = $authorization_code; |
|
|
|
|
$result = $this->curlPost($url, json_encode($data)); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => $result, 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
$result = json_decode($result, true); |
|
|
|
|
if ($result && !empty($result['authorization_info']) && !empty($result['authorization_info']['authorizer_appid'])) { |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '获取详情' . $authorization_code, 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=' . $this->getComponentAccessToken(); |
|
|
|
|
$data = []; |
|
|
|
|
$data['component_appid'] = self::APPID; |
|
|
|
|
$data['authorizer_appid'] = $result['authorization_info']['authorizer_appid']; |
|
|
|
|
$res = $this->curlPost($url, json_encode($data)); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => $res, 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
$res = json_decode($res, true); |
|
|
|
|
if ($res && !empty($res['authorizer_info']) && !empty($res['authorization_info'])) { |
|
|
|
|
$authorizer_info = $res['authorizer_info']; |
|
|
|
|