一、微信公众平台配置
登陆微信公众平台
开发->接口权限->网页服务->网页授权获取用户基本信息->修改
在弹出框中输入申请的某**壳免费域名:j*s**x***.imwork.NET
![](https://img-blog.csdn.net/20160630094122104?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
微信公众平台升级之后的增加第3步下载.txt文件上传至服务器
![](https://img-blog.csdn.net/20170103135443508?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveGlhb3NodWpp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
二、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/51602043
3.部分代码
- 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端口