mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-04-06 03:58:03 +08:00
[更新]增加微信小程序登录解码测试
This commit is contained in:
parent
2c57405e97
commit
d05c98099e
20
Test/mini-login.php
Normal file
20
Test/mini-login.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include '../include.php';
|
||||
|
||||
// 小程序配置
|
||||
$config = [
|
||||
'appid' => 'wx6bb7b70258da09c6',
|
||||
'appsecret' => '78b7b8d65bd67b078babf951d4342b42',
|
||||
];
|
||||
|
||||
// 解码数据
|
||||
$iv = 'ltM/wT7hsAl0TijEBI4v/g==';
|
||||
$code = '013LyiTR0TwjC92QjJRR0mEsTR0LyiT3';
|
||||
$decode = 'eIoVtIC2YzLCnrwiIs1IBbXMvC0vyL8bo1IhD38fUQIRbk3lgTWa0Hdw/Ty7NTs3iu7YlqqZBti+cxd6dCfeXBUQwTO2QpbHg0WTeDAdrihsHRHm4dCWdfTx8rzDloGbNOIsKdRElIhUH5YFdiTr5AYiufUDb34cwJ4GNWLAUq4bR0dmFeVEi+3nfwe2MAjGYDl4aq719VLsHodOggK6lXZvM5wjoDyuZsK2dPqJr3/Ji30Z0mdyFq32R4uR3rtJH/h+Rj0+/QmE9QYG7Y6Z48hgPE8cpnhRQNwH49jnC/zKZ9wtDkQ/J8J3Ed2i58zcuY01v8IV+pZ8oBUKXfO5ha+APOxtBSTzyHraU/2RGo8UWtOF6h64OQZhd/UQQy362eyc/qoq8sF9JnEFRP0mRmTDJ+u9oyDhxswCu6x8V73ERWaJeEGSCyjiGpep7/DxZ6eSSBq36OB0BWBkJqsq9Q==';
|
||||
$sessionKey = 'OetNxl86B/yMpbwG6wtMEw==';
|
||||
$mini = new WeMini\Crypt($config);
|
||||
echo '<pre>';
|
||||
//print_r($mini->session($code));
|
||||
print_r($mini->decode($iv, $sessionKey, $decode));
|
||||
//print_r($mini->userInfo($code, $iv, $decode));
|
@ -41,7 +41,7 @@ class Crypt extends BasicWeChat
|
||||
$pc = new \WXBizDataCrypt($this->config->get('appid'), $sessionKey);
|
||||
$errCode = $pc->decryptData($encryptedData, $iv, $data);
|
||||
if ($errCode == 0) {
|
||||
return $data;
|
||||
return json_decode($data, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -72,7 +72,7 @@ class Crypt extends BasicWeChat
|
||||
{
|
||||
$result = $this->session($code);
|
||||
if (empty($result['session_key'])) {
|
||||
throw new InvalidResponseException('Code换取SessionKey失败', 403);
|
||||
throw new InvalidResponseException('Code 换取 SessionKey 失败', 403);
|
||||
}
|
||||
$userinfo = $this->decode($iv, $result['session_key'], $encryptedData);
|
||||
if (empty($userinfo)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user