You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< ? php
namespace tencent\wechat\mpweixin ;
use EasyWeChat\Factory ;
class User extends Base
{
/**
* 通过登录凭证获取用户信息
* @param string $code 登录凭证
* @date 2022-02-09
*/
public function getOpenid ( $code )
{
$app = Factory :: miniProgram ( $this -> mpWeixinConfig );
$data = $app -> auth -> session ( $code );
//记录三方日志
$uid = defined ( 'UID' ) ? UID : '' ;
platformLog ([ 'code' => $code ], $data , 'mpweixin_get_openid_uid_' . $uid );
return $data ;
}
/**
* 通过code换取用户手机号
* @param string $code
* @date 2022-02-10
*/
public function getPhoneNumber ( $code )
{
$app = Factory :: miniProgram ( $this -> mpWeixinConfig );
$data = $app -> phone_number -> getUserPhoneNumber ( $code );
// 记录三方日志
$uid = defined ( 'UID' ) ? UID : '' ;
platformLog ([ 'code' => $code ], $data , 'mpweixin_get_phone_number_uid_' . $uid );
return $data ;
}
/**
* 通过code换取用户手机号( 废弃)
* @param string $code
* @date 2022-02-10
*/
public function getPhoneNumber1 ( $session , $iv , $encryptedData )
{
$app = Factory :: miniProgram ( $this -> mpWeixinConfig );
$data = $app -> encryptor -> decryptData ( $session , $iv , $encryptedData );
return $data ;
}
}