|
@@ -0,0 +1,29 @@
|
|
|
|
+package com.management.platform.util;
|
|
|
|
+
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 私有化部署的url生成器
|
|
|
|
+ */
|
|
|
|
+public class PrivateDeployUrlGenerator {
|
|
|
|
+ //企业微信私有化部署的url生成器;如果访问的网址带端口号,这里也带上传参
|
|
|
|
+ public static String generateCorpWXUrl(String corpId, String agentId, String redirectUrl) {
|
|
|
|
+ try {
|
|
|
|
+ if (redirectUrl.endsWith("/")) {
|
|
|
|
+ redirectUrl = redirectUrl.substring(0, redirectUrl.length()-1);
|
|
|
|
+ }
|
|
|
|
+ String redirectUrlEncoded = URLEncoder.encode(redirectUrl+"/api/corpInsideWXAuth", "UTF-8");
|
|
|
|
+ String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+corpId
|
|
|
|
+ +"&redirect_uri="+redirectUrlEncoded+"&response_type=code&scope=snsapi_base&state=0&agentid="+agentId+"#wechat_redirect";
|
|
|
|
+ return url;
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ //测试生成企业微信私有化部署的url,替换参数,生成的结果提供给客户,让客户配置到企业微信自建应用的【应用主页】上
|
|
|
|
+ System.out.println(generateCorpWXUrl("ww4e237fd6abb635af", "1000002", "http://worktime.ttkuaiban.com"));
|
|
|
|
+ }
|
|
|
|
+}
|