zoukankan      html  css  js  c++  java
  • 【微信H5】 Redirect_uri参数错误解决方法


    1
    https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx14127af0bc9fd367&redirect_uri=http%3A%2F%2Ffbh5.wx.pre.qsepay.com%2Fbzinsh5%2Fpersonal%2Ffbwap.htm%3Fsource%3Dwage%26debug%3D1&response_type=code&scope=snsapi_base&state=&connect_redirect=1#wechat_redirect

    1.0 引子

    如上所示,就是我们报错的url,下面就捋一捋我项目中的使用吧

    redirect_uri 在我的项目中一般是取当前项目的url,用于获取授权auth_code

    
    
    <!--微信 授权都是通过code换取openid   分为 隐式授权(snsapi_base) / 显式授权(snsapi_userinfo)-->
    /**
     * 隐式授权(snsapi_base) 不弹窗 (显示授权同意后,可以使用此方式获取用户信息)
     */
    function toAuthorize(){
          var URIString=encodeURIComponent(window.location.href);
          window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri="+URIString+"&response_type=code&scope=snsapi_base&state=#wechat_redirect";
    }
    /**
     * 显式授权(snsapi_userinfo) 弹出 "是否允许该网站获取头像,昵称信息" 确认窗口
     */
    function toAuthorizeX(){
          var hrefstr=window.location.href;
          if(hrefstr.indexOf("code=")!=-1){
             hrefstr= hrefstr.substr(0,hrefstr.indexOf("code="));
          }
          var URIString=encodeURIComponent(hrefstr);
           window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri="+URIString+"&response_type=code&scope=snsapi_userinfo&state=#wechat_redirect";
    
    }
    
    

    2.0 分析错误

    2.1 有问题找官网 http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html

    2.2 友情提示:

    网页授权的域名跟 Redirect_uri 所指向的页面的域名不一致 
    比如:你授权的 域名是 http://m.qsepay.com
    你网页跳转的 url 是 http://m.qsepay.com/bzinsh5

    这两个很明显不是在同一个域名下,你需要把 Redirect_uri 设置为:http://m.qsepay.com/bzinsh5

    
    
  • 相关阅读:
    XML案例
    4.6Java数组的遍历
    4.3Java多态(polymorphism)
    XML文档的标准
    4.6Java数组的定义
    4.6Java数组初始化的方式
    XML介绍
    4.6Java对象转型(casting)
    HelloWorld之MyBatis
    Hibernate查询方法比较
  • 原文地址:https://www.cnblogs.com/Profound/p/6801995.html
Copyright © 2011-2022 走看看