哪个微信开发文档传送什么参数我就不写
第一步拿到开放平台的登录令牌
public static String loginToken(EssentialInfo essentialInfo){ net.sf.json.JSONObject accessTokenRequest =new net.sf.json.JSONObject();//第三方平台临时令牌请求 accessTokenRequest.put("component_appid",Configure.getValue("AppID")); accessTokenRequest.put("component_appsecret",Configure.getValue("AppSecret")); accessTokenRequest.put("component_verify_ticket",essentialInfo.getRemark()); net.sf.json.JSONObject accessTokenCallback= WxstoreUtils.httpRequest("https://api.weixin.qq.com/cgi-bin/component/api_component_token","POST",accessTokenRequest.toString()); // JSONArray js=bs.getJSONArray("component_access_token"); String accessToken=accessTokenCallback.getString("component_access_token");//accessTokenCallback 第三方平台临时令牌请求回调 return accessToken; }
第二步 获取预授权码
/** * 获取扫描公众号的路径 * @return */ public static String authorized( EssentialInfo essentialInfo){ String accessToken= loginToken(essentialInfo); net.sf.json.JSONObject preAuthRequest=new net.sf.json.JSONObject();//preAuthRequest 预授权请求 preAuthRequest.put("component_appid",Configure.getValue("AppID")); preAuthRequest.put("component_appsecret", Configure.getValue("AppSecret")); net.sf.json.JSONObject preAuthCallback= WxstoreUtils.httpRequest("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token="+accessToken,"POST",preAuthRequest.toString()); Map<String,Object> preAuthMap=(Map<String,Object>)preAuthCallback;//preAuthMap 预授权转换map String preAuthCode=(String)preAuthMap.get("pre_auth_code");//预授权码 String authorizationPath="https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid="+Configure.getValue("AppID")+"&pre_auth_code="+preAuthCode+"&redirect_uri=" + Configure.getValue("MAEAURL");//authorizationPath 授权路径 return authorizationPath; }
authorizationPath 这就是具体要跳转的路径 你想怎么跳都行;