1.開發程序中使用的是ngrok做的內網穿透
2.獲取code的代碼如下
String appID="";
String appsecret="";
String redirect_uri="http://**.ngrok.cc/project/yinda";
String code=null;
//獲取code的url
String codeUrl="https://open.weixin.qq.com/connect/oauth2/authorize?"
+ "appid="+appID
+"&redirect_uri="+redirect_uri
+"&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
String access_tokenUrl="https://api.weixin.qq.com/sns/oauth2/access_token?"
+ "appid="+appID
+ "&secret="+appsecret
+ "&code="+code
+ "&grant_type=authorization_code";
code = request.getParameter("code");
System.out.println(code);
if(code == null || "".equals(code)){
response.sendRedirect(codeUrl);
}else{
response.sendRedirect("http://www.baidu.com");
}
}
3.公眾號測驗時第一次進入微信公眾號獲得的code為null,然后執行了response.sendRedirect(codeUrl),之后代碼就不執行了,這是因為我使用ngrok的原因還是我本身代碼哪里寫錯了呢,求大神解惑
uj5u.com熱心網友回復:
樓主解決了嗎uj5u.com熱心網友回復:
解決了嗎樓主,希望得到回應謝謝轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/171547.html
標籤:微信開發
下一篇:qt呼叫簡單udp程式出錯!
