|
@@ -78,7 +78,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
|
|
|
|
|
|
public void userAuthenticated(String userId) throws WxErrorException { |
|
|
public void userAuthenticated(String userId) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?userid=" + userId; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?userid=" + userId; |
|
|
execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
get(url, null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public String getAccessToken() throws WxErrorException { |
|
|
public String getAccessToken() throws WxErrorException { |
|
@@ -123,23 +123,23 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
|
|
|
|
|
|
public void messageSend(WxCpMessage message) throws WxErrorException { |
|
|
public void messageSend(WxCpMessage message) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send"; |
|
|
execute(new SimplePostRequestExecutor(), url, message.toJson()); |
|
|
|
|
|
|
|
|
post(url, message.toJson()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void menuCreate(WxMenu menu) throws WxErrorException { |
|
|
public void menuCreate(WxMenu menu) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid=" + wxCpConfigStorage.getAgentId(); |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid=" + wxCpConfigStorage.getAgentId(); |
|
|
execute(new SimplePostRequestExecutor(), url, menu.toJson()); |
|
|
|
|
|
|
|
|
post(url, menu.toJson()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void menuDelete() throws WxErrorException { |
|
|
public void menuDelete() throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + wxCpConfigStorage.getAgentId(); |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + wxCpConfigStorage.getAgentId(); |
|
|
execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
get(url, null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public WxMenu menuGet() throws WxErrorException { |
|
|
public WxMenu menuGet() throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + wxCpConfigStorage.getAgentId(); |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + wxCpConfigStorage.getAgentId(); |
|
|
try { |
|
|
try { |
|
|
String resultContent = execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
String resultContent = get(url, null); |
|
|
return WxMenu.fromJson(resultContent); |
|
|
return WxMenu.fromJson(resultContent); |
|
|
} catch (WxErrorException e) { |
|
|
} catch (WxErrorException e) { |
|
|
// 46003 不存在的菜单数据 |
|
|
// 46003 不存在的菜单数据 |
|
@@ -178,17 +178,17 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
|
|
|
|
|
|
public void departUpdate(WxCpDepart group) throws WxErrorException { |
|
|
public void departUpdate(WxCpDepart group) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/update"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/update"; |
|
|
execute(new SimplePostRequestExecutor(), url, group.toJson()); |
|
|
|
|
|
|
|
|
post(url, group.toJson()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void departDelete(Integer departId) throws WxErrorException { |
|
|
public void departDelete(Integer departId) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/delete?id=" + departId; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/delete?id=" + departId; |
|
|
execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
get(url, null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<WxCpDepart> departGet() throws WxErrorException { |
|
|
public List<WxCpDepart> departGet() throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list"; |
|
|
String responseContent = execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
String responseContent = get(url, null); |
|
|
/* |
|
|
/* |
|
|
* 操蛋的微信API,创建时返回的是 { group : { id : ..., name : ...} } |
|
|
* 操蛋的微信API,创建时返回的是 { group : { id : ..., name : ...} } |
|
|
* 查询时返回的是 { groups : [ { id : ..., name : ..., count : ... }, ... ] } |
|
|
* 查询时返回的是 { groups : [ { id : ..., name : ..., count : ... }, ... ] } |
|
@@ -204,25 +204,25 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
@Override |
|
|
@Override |
|
|
public void userCreate(WxCpUser user) throws WxErrorException { |
|
|
public void userCreate(WxCpUser user) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/create"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/create"; |
|
|
execute(new SimplePostRequestExecutor(), url, user.toJson()); |
|
|
|
|
|
|
|
|
post(url, user.toJson()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void userUpdate(WxCpUser user) throws WxErrorException { |
|
|
public void userUpdate(WxCpUser user) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/update"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/update"; |
|
|
execute(new SimplePostRequestExecutor(), url, user.toJson()); |
|
|
|
|
|
|
|
|
post(url, user.toJson()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void userDelete(String userid) throws WxErrorException { |
|
|
public void userDelete(String userid) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid=" + userid; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid=" + userid; |
|
|
execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
get(url, null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public WxCpUser userGet(String userid) throws WxErrorException { |
|
|
public WxCpUser userGet(String userid) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid=" + userid; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid=" + userid; |
|
|
String responseContent = execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
String responseContent = get(url, null); |
|
|
return WxCpUser.fromJson(responseContent); |
|
|
return WxCpUser.fromJson(responseContent); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -239,7 +239,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
params += "&status=0"; |
|
|
params += "&status=0"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String responseContent = execute(new SimpleGetRequestExecutor(), url, params); |
|
|
|
|
|
|
|
|
String responseContent = get(url, params); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
return WxCpGsonBuilder.INSTANCE.create() |
|
|
return WxCpGsonBuilder.INSTANCE.create() |
|
|
.fromJson( |
|
|
.fromJson( |
|
@@ -253,7 +253,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/create"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/create"; |
|
|
JsonObject o = new JsonObject(); |
|
|
JsonObject o = new JsonObject(); |
|
|
o.addProperty("tagname", tagName); |
|
|
o.addProperty("tagname", tagName); |
|
|
String responseContent = execute(new SimplePostRequestExecutor(), url, o.toString()); |
|
|
|
|
|
|
|
|
String responseContent = post(url, o.toString()); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
return tmpJsonElement.getAsJsonObject().get("tagid").getAsString(); |
|
|
return tmpJsonElement.getAsJsonObject().get("tagid").getAsString(); |
|
|
} |
|
|
} |
|
@@ -264,19 +264,19 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
JsonObject o = new JsonObject(); |
|
|
JsonObject o = new JsonObject(); |
|
|
o.addProperty("tagid", tagId); |
|
|
o.addProperty("tagid", tagId); |
|
|
o.addProperty("tagname", tagName); |
|
|
o.addProperty("tagname", tagName); |
|
|
execute(new SimplePostRequestExecutor(), url, o.toString()); |
|
|
|
|
|
|
|
|
post(url, o.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void tagDelete(String tagId) throws WxErrorException { |
|
|
public void tagDelete(String tagId) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?tagid=" + tagId; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?tagid=" + tagId; |
|
|
execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
get(url, null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<WxCpTag> tagGet() throws WxErrorException { |
|
|
public List<WxCpTag> tagGet() throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/list"; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/list"; |
|
|
String responseContent = execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
String responseContent = get(url, null); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
return WxCpGsonBuilder.INSTANCE.create() |
|
|
return WxCpGsonBuilder.INSTANCE.create() |
|
|
.fromJson( |
|
|
.fromJson( |
|
@@ -288,7 +288,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
@Override |
|
|
@Override |
|
|
public List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException { |
|
|
public List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException { |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagid=" + tagId; |
|
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/get?tagid=" + tagId; |
|
|
String responseContent = execute(new SimpleGetRequestExecutor(), url, null); |
|
|
|
|
|
|
|
|
String responseContent = get(url, null); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
return WxCpGsonBuilder.INSTANCE.create() |
|
|
return WxCpGsonBuilder.INSTANCE.create() |
|
|
.fromJson( |
|
|
.fromJson( |
|
@@ -307,7 +307,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
jsonArray.add(new JsonPrimitive(userId)); |
|
|
jsonArray.add(new JsonPrimitive(userId)); |
|
|
} |
|
|
} |
|
|
jsonObject.add("userlist", jsonArray); |
|
|
jsonObject.add("userlist", jsonArray); |
|
|
execute(new SimplePostRequestExecutor(), url, jsonObject.toString()); |
|
|
|
|
|
|
|
|
post(url, jsonObject.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@@ -320,7 +320,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
jsonArray.add(new JsonPrimitive(userId)); |
|
|
jsonArray.add(new JsonPrimitive(userId)); |
|
|
} |
|
|
} |
|
|
jsonObject.add("userlist", jsonArray); |
|
|
jsonObject.add("userlist", jsonArray); |
|
|
execute(new SimplePostRequestExecutor(), url, jsonObject.toString()); |
|
|
|
|
|
|
|
|
post(url, jsonObject.toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@@ -365,7 +365,7 @@ public class WxCpServiceImpl implements WxCpService { |
|
|
if (StringUtils.isNotEmpty(inviteTips)) { |
|
|
if (StringUtils.isNotEmpty(inviteTips)) { |
|
|
jsonObject.addProperty("invite_tips", inviteTips); |
|
|
jsonObject.addProperty("invite_tips", inviteTips); |
|
|
} |
|
|
} |
|
|
String responseContent = execute(new SimplePostRequestExecutor(), url, jsonObject.toString()); |
|
|
|
|
|
|
|
|
String responseContent = post(url, jsonObject.toString()); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); |
|
|
return tmpJsonElement.getAsJsonObject().get("type").getAsInt(); |
|
|
return tmpJsonElement.getAsJsonObject().get("type").getAsInt(); |
|
|
} |
|
|
} |
|
|