|
@@ -1,5 +1,8 @@
|
|
|
package com.zskk.service;
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+
|
|
|
import com.jfinal.weixin.sdk.api.SnsAccessToken;
|
|
|
import com.jfinal.weixin.sdk.api.SnsAccessTokenApi;
|
|
|
|
|
@@ -8,9 +11,11 @@ public class WeixinService {
|
|
|
/**
|
|
|
* 用户同意授权,获取带code的url
|
|
|
* @return
|
|
|
+ * @throws UnsupportedEncodingException
|
|
|
*/
|
|
|
- public String getCodeUrl(String appId, String redirect_uri) {
|
|
|
- String url = SnsAccessTokenApi.getAuthorizeURL(appId, redirect_uri, false);
|
|
|
+ public String getCodeUrl(String appId, String redirect_uri) throws UnsupportedEncodingException {
|
|
|
+ String encode = URLEncoder.encode(redirect_uri, "UTF-8");
|
|
|
+ String url = SnsAccessTokenApi.getAuthorizeURL(appId, encode, false);
|
|
|
return url;
|
|
|
}
|
|
|
|
|
@@ -18,4 +23,17 @@ public class WeixinService {
|
|
|
SnsAccessToken snsAccessToken = SnsAccessTokenApi.getSnsAccessToken(appId, secret, code);
|
|
|
return snsAccessToken;
|
|
|
}
|
|
|
+
|
|
|
+// public static void main(String[] args) {
|
|
|
+// try {
|
|
|
+// String url = URLEncoder.encode("http://wechat.client.pacsonline.cn/#/bind", "UTF-8");
|
|
|
+// String ssString = getCodeUrl("wxee1c68f8944d357b", url);
|
|
|
+// System.out.println(ssString);
|
|
|
+// } catch (UnsupportedEncodingException e) {
|
|
|
+// // TODO Auto-generated catch block
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
}
|