@Override
public String getShareQrCode(String weChatId) throws Exception {
String url = String.format(WeChatConstant.GET_PARAM_QR_CODE_URL, getAuthToken());
String params = String.format(WeChatConstant.GET_QR_CODE_BODY, weChatId);
String response = HttpUtil.post(url, params);
String authToken = getAuthToken();
if (StrUtil.isNotEmpty(response)){
JSONObject jsonObject = JSONUtil.parseObj(response);
String ticket = Convert.toStr(jsonObject.get("ticket"));
File qrCodeFile = downloadQRCode(String.format(WeChatConstant.GET_PARAM_QR_CODE_TICKET_URL, ticket), "qrcode.jpg");
if (qrCodeFile != null) {
String uploadUrl = String.format(WeChatConstant.UPLOAD_IMAGE_URL, authToken);
String result = uploadImageToWeChat(uploadUrl, qrCodeFile);
JSONObject urlObj = JSONUtil.parseObj(result);
System.out.println("WeChat API Response: " + result);
String replaceUrl = urlObj.get("url", String.class).replaceAll("\\\\", "");
return replaceUrl;
}
}
return null;
}
上述result 返回的数据只有url, replaceUrl 为图片的网络地址, 如何通过replaceUrl换取mediaId, 因为我需要将上述图片回复图片消息:
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>12345678</CreateTime>
<MsgType><![CDATA[image]]></MsgType>
<Image>
<MediaId><![CDATA[media_id]]></MediaId>
</Image>
</xml>
这里我需要传入mediaId
发postman调用截图,不想看你代码