php 微信授权登录 40029错误[通俗易懂]

php 微信授权登录 40029错误[通俗易懂]php微信授权登录40029错误授权登录是微信高级api,个人开发可以使用微信测试账号进行开发。在授权的过程可能出现40029错误码,解决的方法可以通过将code写在session里。publicfunctiongetUserDetail(){$appid=”xxxxxxxxxxxx”;$redirect_uri=urlencode(“

大家好,又见面了,我是你们的朋友全栈君。

php 微信授权登录 40029错误

授权登录是微信高级api,个人开发可以使用微信测试账号进行开发。
在授权的过程可能出现40029错误码,
解决的方法可以通过将code 写在session里。


public function getUserDetail(){ 
   
        $appid = "xxxxxxxxxxxx";
        $redirect_uri = urlencode("www.xxx你的后台入口xx.com/getUserInfo");

        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$appid.'&redirect_uri='.$redirect_uri.'&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect';
        header('location:'.$url);
    }

public function getUserInfo(){ 
   
        $appid = "xxxxxxx";
        $appsecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

        $code   = $_GET['code'];

        if ($_SESSION[$code]) {
  
  //判断是否已经存在,如存在直接使用code
        //先获取token
            $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$appid.'&secret='.$appsecret.'&code='.$code.'&grant_type=authorization_code';
            $res = $this->http_curl($url,'get');
            $access_token = $res['access_token'];
            $openid = $res['openid'];
            var_dump($access_token);
            //获取信息
            $url = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$access_token.'&openid='.$openid.'&lang=zh_CN';
            $res = $this->http_curl($url);
            var_dump($res);
        } else {
            $_SESSION[$code] = $code;
        }
    }
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/131236.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • tle代码

    tle代码include iostream include string include cstring usingnamespa typedeflongl intn k 1 p 0 maxn strings intmain cin gt gt n cin gt amp cstring string iostream

    2025年6月23日
    1
  • python hashlib_python import hashlib出现问题

    python hashlib_python import hashlib出现问题importhashlib时出现如下问题:>>>importhashlibERROR:root:codeforhashmd5wasnotfound.Traceback(mostrecentcalllast):File”/usr/local/python3.2/lib/python3.2/hashlib.py”,line141,inglobals()[__func…

    2022年6月12日
    43
  • mtk驱动安装_UBOOT下U盘驱动移植

    mtk驱动安装_UBOOT下U盘驱动移植对于MTKCamera驱动移植一般分为四部分:1、硬件IO口配置;2、Camera驱动移植;3、上电时序;4、修改i2c控制器;硬件电路:1、GPIO配置打开 mediatek\dct\DrvGen.exe 选择mediatek\custom\xiaoxi\kernel\dct\dct\codegen.

    2025年7月22日
    2
  • .pfx数字证书制作及操作使用

    .pfx数字证书制作及操作使用#.pfx数字证书制作及操作使用使用工具.pfx创建从*.pfx文件提取密钥Java代码操作#工具下载地址链接:http://pan.baidu.com/s/1jHOyIQa密码:aund#创建.pfxCN=名称(一般填公司名称)OU=单位名称O=作者名称L=地区C=国家第一步打开CertManager

    2022年5月20日
    148
  • java删除linux文件_Java删除文件

    java删除linux文件_Java删除文件//将缓冲文件夹中的文件删除Strings=”D:\\txt\\inBuffer\\”+fileInfo[0]+”\\”+fileID;//文件的绝对路径Filefile=newFile(s);if(file.exists()){booleand=file.delete();if(d){System.out.print(“删除成功!”);}else{System.out…

    2022年6月14日
    102
  • visio产品密钥2016_visio产品密钥2003

    visio产品密钥2016_visio产品密钥2003http://blog.sina.com.cn/s/blog_4e0869690100z9m3.htmlVisioPremium2010VOL版:=========================F…

    2022年8月13日
    7

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号