|
|
|
@ -272,6 +272,22 @@ class MiniService extends Service
|
|
|
|
|
->toArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检验数据的真实性,并且获取解密后的明文.
|
|
|
|
|
* @param string $js_code
|
|
|
|
|
* @param string $encrypted_data
|
|
|
|
|
* @param string $iv
|
|
|
|
|
* @return bool|mixed
|
|
|
|
|
* @throws CurlException
|
|
|
|
|
*/
|
|
|
|
|
public function userInfo(string $js_code, string $encrypted_data, string $iv)
|
|
|
|
|
{
|
|
|
|
|
$session = $this->code2Session($js_code);
|
|
|
|
|
if (!isset($session['openid'])) return false;
|
|
|
|
|
$result = openssl_decrypt(base64_decode($encrypted_data), "AES-128-CBC", base64_decode($session['session_key']), 1, base64_decode($iv));
|
|
|
|
|
return json_decode($result, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取小程序全局唯一后台接口调用凭据(access_token)
|
|
|
|
|
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
|
|
|
|
|