一、微信公衆平臺配置
登陸微信公衆平臺
開發->接口權限->網頁服務->網頁授權獲取用戶基本信息->修改
在彈出框中輸入申請的某**殼免費域名:j*s**x***.imwork.net
微信公衆平臺升級之後的增加第3步下載.txt文件上傳至服務器
二、http
1.路由器上配置80端口指向自己的電腦相應tomcat端口
2.部分代碼
public String prequery(HttpServletRequest request, HttpServletResponse reponse) throws Exception {
logger.info("query-elec");
String oauthUrl = String.format(OAUTH_CODE_URL,
PoolWeixinConfig.getConfig().getAppId(),
URLEncoder.encode("http://j*s**x***.imwork.net/sypro/site/bind/info/query", "UTF-8"));
logger.info("redirect:" + oauthUrl);
return "redirect:" + oauthUrl;
}
protected static final String OAUTH_CODE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=req#wechat_redirect";
三、https
1.路由器上配置443端口指向自己的電腦相應tomcat端口
2.tomcat配置ssl協議(server.xml) <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="D:\certs_weixin\tomcat.keystore" keystorePass="******" ciphers="tomcat"
/>
具體配置參見:http://blog.csdn.net/xiaoshuji/article/details/516020433.部分代碼
public String prequery(HttpServletRequest request, HttpServletResponse reponse) throws Exception {
logger.info("query-elec");
String oauthUrl = String.format(OAUTH_CODE_URL,
PoolWeixinConfig.getConfig().getAppId(),
URLEncoder.encode("https://j*s**x***.imwork.net/sypro/site/bind/info/query", "UTF-8"));
logger.info("redirect:" + oauthUrl);
return "redirect:" + oauthUrl;
}
四、注意
回調redirect_uri不要加端口否則會報參數錯誤,默認支持80,443端口