zno2

生成带参数的二维码

spring bean

    <!-- 微信配置 -->
    <bean id="wxMpConfigStorage" class="me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage">
        <property name="appId" value="#{config[\'mp.appId\']}"></property>
        <property name="secret" value="#{config[\'mp.secret\']}"></property>
        <property name="token" value="#{config[\'mp.token\']}"></property>
    </bean>

 

java 服务类

    @Autowired
    private WxMpConfigStorage wxMpConfigStorage; 
private WxMpService wxMpService;
/** * 获取第三方微信服务类 * */ public WxMpService getWxMpService(){ if(wxMpService == null){ WxMpService wxMpService = new WxMpServiceImpl(); wxMpService.setWxMpConfigStorage(wxMpConfigStorage); this.wxMpService = wxMpService; return wxMpService; }else{ return wxMpService; } }

 

测试类

    @Autowired
    private WeixinService weixinService;
    
    @Test
    public void createCode() throws WxErrorException{
        WxMpService wxMpService = weixinService.getWxMpService();
        WxMpQrCodeTicket ticket = wxMpService.qrCodeCreateLastTicket("abc");
        String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket;
        System.out.println(url);
    }

 

注意:

生成带参数的二维码

 

未授权时调用报错:

{"errcode":48001,"errmsg":"api unauthorized hint: [KQ2xDA0318vr22]"}

分类:

技术点:

相关文章:

  • 2022-02-15
  • 2021-11-23
  • 2022-01-11
  • 2021-12-05
  • 2021-12-08
  • 2021-12-12
猜你喜欢
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2022-12-23
  • 2021-12-05
  • 2021-08-24
  • 2021-12-05
相关资源
相似解决方案