me.chanjar.weixin.mp.api.WxMpService.createJsapiSignature()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(689)

本文整理了Java中me.chanjar.weixin.mp.api.WxMpService.createJsapiSignature()方法的一些代码示例,展示了WxMpService.createJsapiSignature()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WxMpService.createJsapiSignature()方法的具体详情如下:
包路径:me.chanjar.weixin.mp.api.WxMpService
类名称:WxMpService
方法名:createJsapiSignature

WxMpService.createJsapiSignature介绍

[英]```
创建调用jsapi时所需要的签名
详情请见:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95

[中]```
创建调用jsapi时所需要的签名 
详情请见:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95

代码示例

代码示例来源:origin: com.github.hippoom/wechat-mp-autoconfigure

/**
 * see <a href="http://admin.wechat.com/wiki/index.php?title=JS_SDK_DOCUMENT#Step_3:_Inject_Correct_Authentication_Configuration_via_the_config_API">
 * Inject Correct Authentication Configuration via the config API
 * </a>.
 *
 * @param url the URL to signature
 * @return {@link WxJsapiSignature}
 * @throws WxErrorException 5XX
 */
@RequestMapping(value = "/wechat/mp/js/config", method = GET)
protected WxJsapiSignature askForConfig(@RequestParam(name = "url") String url)
  throws WxErrorException {
  return weChatMpService.createJsapiSignature(url);
}

代码示例来源:origin: aillamsun/genesis

/**
 * @return Map<String, Object>    返回类型
 * @throws WxErrorException
 * @throws
 * @Title: signatureUrl
 * @Description: TODO  对微信WEB 访问的URL 进行签名 否则无法使用 JSSDK
 */
public static Map<String, Object> signatureUrl(String signurl) throws WxErrorException {
  Map<String, Object> shareConfig = new HashMap<String, Object>();
  WxJsapiSignature wxJsapiSignature = null;
  wxJsapiSignature = WxMpServiceFactory.getWxMpService().createJsapiSignature(signurl);
  if (wxJsapiSignature == null) {
    return shareConfig;
  }
  shareConfig.put("timestamp", wxJsapiSignature.getTimestamp());
  shareConfig.put("nonceStr", wxJsapiSignature.getNoncestr());
  shareConfig.put("signature", wxJsapiSignature.getSignature());
  shareConfig.put("appId", WechatConfig.WEB_APP_ID);
  shareConfig.put("url", signurl);
  return shareConfig;
}

代码示例来源:origin: liuweijw/fw-cloud-framework

@RequestMapping(value = "/wechatParam")
@ResponseBody
public HttpResult wechatParam(@RequestParam("url") String url) {
  long start = System.currentTimeMillis();
  if (StringHelper.isBlank(url)) return new HttpResult().failure("url 参数验证失败!");
  String jsdkUrl = WebUtils.buildURLDecoder(url);
  try {
    WxJsapiSignature jsapi = wxService.createJsapiSignature(WebUtils
        .buildURLDecoder(jsdkUrl));
    log.info("[微信jsdk],请求{},获取耗时{}", jsdkUrl, (System.currentTimeMillis() - start));
    return new HttpResult().data(jsapi).success();
  } catch (WxErrorException e) {
    e.printStackTrace();
  }
  return new HttpResult().failure("获取微信签名数据失败!");
}

相关文章