求助,谁做过微信小程序生成小程序码?

求助,谁做过微信小程序生成小程序码的功能?

我先用appId和secret获取access_tocken, 然后直接拿去获取微信小程序码就会报错,意思是tocken不是最新的。明明是上面刚刚获取到的。

代码如下:

  @Test
    public void httpTest() throws JSONException{
    	
        String url = "https://api.weixin.qq.com/cgi-bin/token";
        String params ="grant_type=client_credential&appid="+ appId +"&secret=" + secret;
        String result = HttpRequest.sendGet(url,params);
        System.out.println("---->");
        String tocken = result.toLowerCase();
        org.json.JSONObject json = new org.json.JSONObject(tocken);
        String tockenStr = json.getString("access_token");
        System.out.println("----------------------");
        System.out.println(tockenStr);
        String Codeurl = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + tockenStr;
        
        
        
        System.out.println(Codeurl);
        String codeParms = "page=/pages/index/index&width=200&scene=1&is_hyaline=false&auto_color=false&line_color={“r”:”0”,”g”:”0”,”b”:”0”}";
        String codeRes = HttpRequest.sendPost(Codeurl, codeParms);
        System.out.println("获取二维码成功!");
        System.out.println(codeRes);
        
    }
复制代码

返回的结果如下:

{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hint: [rumeza0465z782!]"}
复制代码

tocken 是可以正常获取的。就是不知道哪个步骤出了问题。求大神帮忙解答啊!

转载于:https://juejin.im/post/5afe29876fb9a07ab458db25

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值