解密微信绑定的手机号

admin8个月前Laravel447

public function mobile()
{
    $code = request()->input('code'); if (!$code) { return $this->error('请输入code');
    }
    $data['code'] = $code;
    $url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" . $this->Token();
    $info = $this->http_request($url, json_encode($data), 'json');
    $tmpinfo = json_decode($info, true); if ($tmpinfo['errcode'] == '0' && $tmpinfo['errmsg'] == 'ok') {
        $phone = $tmpinfo['phone_info']['phoneNumber']; Db::beginTransaction();
        $code = Db::table('users')->where(array('id' => $this->user_id))->update(['mobile' => $phone]); if ($code !== false) { Db::commit(); return $this->success('ok', $phone);
        } else { Db::rollBack(); return $this->error('绑定失败');
        }
    } else { return $this->error('绑定失败');
    }
}


public function http_request($url, $data = null)
{
    $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json'  ));
    } curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    $output = curl_exec($curl); curl_close($curl); return $output;
}


相关文章

关注公众号并登录

/* * 服务端生成带唯一标识二维码并将唯一标识返回给前端 */ public function wx_code() { $scene_str = $this->get_...

微信支付V2

   public static function unifiedorder($openid, $out_trade_no, $total_fee, $notify)...

生成二维码

public function qrcode($uid){    require_once base_path() . '/public/phpqrcode/phpqrco...

excel 导出

header("Content-Type: application/vnd.ms-excel; name='excel'"); header("Content-Disposition:atta...

公众号登录

public function wxlogin(){       $code = request()->input('code'); &n...

两个经纬度之间的距离

    public function haversineGreatCircleDistance($latitude1, $longitude1, $latitude2, $lon...