作者 王智

daima

... ... @@ -781,6 +781,25 @@ class User extends Api
*/
public function MobileVi()
{
$param = $this->request->param();
//SessionKey
$ch = curl_init();
$appid = "wx55afbe753b153a68";
$secret = "428f6ca70764b0fceee65e1d4991f50a";
$code = $param['code'];
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$secret&js_code=$code&grant_type=authorization_code";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
if ($output === FALSE) {
echo "CURL Error:" . curl_error($ch);
}
curl_close($ch);
$curl_result = json_decode($output, true);
$sessionKey = $curl_result['sessionKey'];
$options = [
'mini_program' => [
'app_id' => 'component-app-id',
... ... @@ -791,8 +810,7 @@ class User extends Api
];
$app = new Application($options);
$miniProgram = $app->mini_program;
$param = $this->request->param();
$mobile = $miniProgram->encryptor->decryptData($param['sessionKey'], $param['iv'], $param['encryptedData']);
$mobile = $miniProgram->encryptor->decryptData($sessionKey, $param['iv'], $param['encryptedData']);
$this->success('成功', $mobile);
}
}
... ...