|
@@ -85,6 +85,24 @@ class User extends Api
|
|
|
$this->success(__('success'),$info);
|
|
|
}
|
|
|
|
|
|
+ //获取手机号
|
|
|
+ public function getPhoneNumber() {
|
|
|
+ // code值
|
|
|
+ $code = $this->request->param('code');
|
|
|
+ if (!$code) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //手机号
|
|
|
+ $wechat = new Wechat();
|
|
|
+ $phoneInfo = $wechat->getPhoneNumber($code);
|
|
|
+ if(isset($phoneInfo['errcode']) && $phoneInfo['errcode'] != 0) {
|
|
|
+ $this->error('获取手机号失败', $phoneInfo['errmsg']);
|
|
|
+ }
|
|
|
+ $mobile = isset($phoneInfo['phone_info']['purePhoneNumber']) ? $phoneInfo['phone_info']['purePhoneNumber'] : '';
|
|
|
+
|
|
|
+ $this->success(1,$mobile);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取用户openid
|
|
@@ -103,10 +121,7 @@ class User extends Api
|
|
|
$this->error('用户openid获取失败',$openidInfo);
|
|
|
}
|
|
|
|
|
|
- //手机号
|
|
|
- /*$wechat = new Wechat();
|
|
|
- $mobile = $wechat->getPhoneNumber($code);
|
|
|
- dump($mobile);*/
|
|
|
+
|
|
|
|
|
|
|
|
|
// 获取的结果存入数据库
|