需求: h5中使用微信的jsSDK,后续实现微信定位以及多图上传
微信文档
申请测试公众号
1.测试公众号进行配置
其中的域名是本地的ip地址
config接口进行权限配置,动态获取JS-SDK权限验证的签名
获取公众号accessToken以及jsTicket
public static String WeChatAppId="wxbb0f4798d5d78b80";
public static String WeChatAppSecret="048680d2d5af8ddf7d05a01c024a02b3";
public static String WeChatToken;
//获取js的ticket
public static String WeChatJsTicket;
public static String WeChatTicketUrl="https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=";
public static String WeChatTokenUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+WeChatAppId+"&secret="+WeChatAppSecret;
public void getTokenTieckt() {
HttpGet get = new HttpGet(WeChatTokenUrl);
String res = HttpClientUtil.get(get, "");
logger.info("==info==>获取微信token res 是 " + "\n" +res);
if (StringUtils.isNotBlank(res)) {
JSONObject json = JSONObject.fromObject(res);
String weChatToken = json.getString("access_token");
WeChatToken = weChatToken;
logger.info("==info==>获取微信token,token 是 " + "\n" + WeChatToken);
}
HttpGet getUrl = new HttpGet(WeChatTicketUrl +WeChatToken);
String resUrl = HttpClientUtil.get(getUrl, "");
logger.info("==info==>获取微信ticket res 是 " + "\n" +resUrl);
if (StringUtils.isNotBlank(resUrl)) {
JSONObject json = JSONObject.fromObject(resUrl);
String weChatticket = j