4.8)另外一些API调用示例,如二维码生产,短链接等


包括如下接口:

  • createQrCode - 生成二维码
  • downloadQrCode - 下载二维码
  • getShortUrl - 获取短链接
  • getCallbackIp - 获取微信服务器ip
1. createQrCode 生成二维码
        WxQrcode code = new WxQrcode();
        code.setAction_name("actionName");
        code.setAction_info(new WxQrActionInfo(new WxScene("scene_id/str")));
        code.setExpire_seconds(720);
        try {
            QrCodeResult result = iService.createQrCode(code);
            System.out.println(result.getUrl());
        } catch (WxErrorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

2. downloadQrCode 下载二维码,需要用到createQrCode中的ticket
        try {
            File file = iService.downloadQrCode(new File("E://temp"), "ticket");
        } catch (WxErrorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

3. getShortUrl 长链接变短链接
        try {
            String shortUrl = iService.getShortUrl("long_url");
        } catch (WxErrorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

4. getCallbackIp获取微信服务器的ip段
        try {
            String [] ipList = iService.getCallbackIp();
        } catch (WxErrorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

results matching ""

    No results matching ""