解密微信绑定的手机号

admin1年前Laravel557

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 dyqrcode($uid){    $url = "https://open.douyin.com/api/apps/v1/qrcode...

发送公众号信息

* 发送消息 */public function tosend($openid, $title, $content, $time, $aid){    $tokens = $thi...

微信支付V3

 public static function pay($order_sn = '11111', $money = '12', $uid = 7) ...

php 优化

使用 gc_collect_cycles() 强制进行垃圾回收 PHP 的垃圾回收机制会自动释放不再使用的变量所占用的内存。然而,在某些情况下,尤其是在长时间运行的脚本(如 CLI...

查找下级所有数据

public function bottom($mid = 3){    $members = DB::select('select id,parent_id,`level...

接口返回处理

public function __construct()    {        $action = request()->rout...