/*
     * 获取token
     */
    private function get_access_token(){
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appleid}&secret={$this->secret}";
        $str = file_get_contents($url);
        $arr = json_decode($str,true);
        if(isset($arr['access_token']) && $arr['access_token'] != ''){
            return $arr['access_token'];
        }else{
            return '';
        }
    }

    /*
     * 获取用户信息
     */
    private function user_info($openid){
        $token = $this->get_access_token();
        $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}&lang=zh_CN";
        $str = file_get_contents($url);
        $arr = json_decode($str,true);
        return $arr;
    }

 参考:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183

    https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839

相关文章:

  • 2021-11-18
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2021-12-02
  • 2021-10-07
猜你喜欢
  • 2021-09-13
  • 2021-11-18
  • 2021-07-31
  • 2021-09-08
  • 2022-12-23
  • 2021-04-30
  • 2021-07-25
相关资源
相似解决方案