mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-03 13:51:44 +08:00
issue #109 企业号几个方法添加agentId参数
This commit is contained in:
@ -155,34 +155,87 @@ public interface WxCpService {
|
|||||||
* <pre>
|
* <pre>
|
||||||
* 自定义菜单创建接口
|
* 自定义菜单创建接口
|
||||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口
|
||||||
|
*
|
||||||
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
|
* @see #menuCreate(String, me.chanjar.weixin.common.bean.WxMenu)
|
||||||
*
|
*
|
||||||
* @param menu
|
* @param menu
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
void menuCreate(WxMenu menu) throws WxErrorException;
|
void menuCreate(WxMenu menu) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 自定义菜单创建接口
|
||||||
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口
|
||||||
|
*
|
||||||
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
|
* </pre>
|
||||||
|
* @see #menuCreate(me.chanjar.weixin.common.bean.WxMenu)
|
||||||
|
*
|
||||||
|
* @param agentId 企业号应用的id
|
||||||
|
* @param menu
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
void menuCreate(String agentId, WxMenu menu) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 自定义菜单删除接口
|
* 自定义菜单删除接口
|
||||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口
|
||||||
|
*
|
||||||
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
|
* @see #menuDelete(String)
|
||||||
*
|
*
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
void menuDelete() throws WxErrorException;
|
void menuDelete() throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 自定义菜单删除接口
|
||||||
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口
|
||||||
|
*
|
||||||
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
|
* </pre>
|
||||||
|
* @see #menuDelete()
|
||||||
|
*
|
||||||
|
* @param agentId 企业号应用的id
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
void menuDelete(String agentId) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 自定义菜单查询接口
|
* 自定义菜单查询接口
|
||||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口
|
||||||
|
*
|
||||||
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
|
* @see #menuGet(String)
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
WxMenu menuGet() throws WxErrorException;
|
WxMenu menuGet() throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 自定义菜单查询接口
|
||||||
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口
|
||||||
|
*
|
||||||
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
|
* </pre>
|
||||||
|
* @see #menuGet()
|
||||||
|
*
|
||||||
|
* @param agentId 企业号应用的id
|
||||||
|
* @return
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
WxMenu menuGet(String agentId) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 部门管理接口 - 创建部门
|
* 部门管理接口 - 创建部门
|
||||||
@ -364,12 +417,33 @@ public interface WxCpService {
|
|||||||
* 用oauth2获取用户信息
|
* 用oauth2获取用户信息
|
||||||
* http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息
|
* http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息
|
||||||
* 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。
|
* 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。
|
||||||
|
*
|
||||||
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
|
* @see #oauth2getUserInfo(String, String)
|
||||||
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return [userid, deviceid]
|
* @return [userid, deviceid]
|
||||||
*/
|
*/
|
||||||
String[] oauth2getUserInfo(String code) throws WxErrorException;
|
String[] oauth2getUserInfo(String code) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 用oauth2获取用户信息
|
||||||
|
* http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息
|
||||||
|
* 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。
|
||||||
|
*
|
||||||
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
|
* </pre>
|
||||||
|
* @see #oauth2getUserInfo(String)
|
||||||
|
*
|
||||||
|
* @param agentId 企业号应用的id
|
||||||
|
* @param code
|
||||||
|
* @return [userid, deviceid]
|
||||||
|
*/
|
||||||
|
String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除标签成员
|
* 移除标签成员
|
||||||
*
|
*
|
||||||
|
|||||||
@ -180,18 +180,36 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
post(url, message.toJson());
|
post(url, message.toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void menuCreate(WxMenu menu) throws WxErrorException {
|
public void menuCreate(WxMenu menu) throws WxErrorException {
|
||||||
|
menuCreate(wxCpConfigStorage.getAgentId(), menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void menuCreate(String agentId, 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();
|
||||||
post(url, menu.toJson());
|
post(url, menu.toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void menuDelete() throws WxErrorException {
|
public void menuDelete() throws WxErrorException {
|
||||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + wxCpConfigStorage.getAgentId();
|
menuDelete(wxCpConfigStorage.getAgentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void menuDelete(String agentId) throws WxErrorException {
|
||||||
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + agentId;
|
||||||
get(url, null);
|
get(url, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public WxMenu menuGet() throws WxErrorException {
|
public WxMenu menuGet() throws WxErrorException {
|
||||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + wxCpConfigStorage.getAgentId();
|
return menuGet(wxCpConfigStorage.getAgentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxMenu menuGet(String agentId) throws WxErrorException {
|
||||||
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + agentId;
|
||||||
try {
|
try {
|
||||||
String resultContent = get(url, null);
|
String resultContent = get(url, null);
|
||||||
return WxMenu.fromJson(resultContent);
|
return WxMenu.fromJson(resultContent);
|
||||||
@ -427,9 +445,14 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] oauth2getUserInfo(String code) throws WxErrorException {
|
public String[] oauth2getUserInfo(String code) throws WxErrorException {
|
||||||
|
return oauth2getUserInfo(code, wxCpConfigStorage.getAgentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException {
|
||||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
|
||||||
+ "code=" + code
|
+ "code=" + code
|
||||||
+ "&agendid=" + wxCpConfigStorage.getAgentId();
|
+ "&agendid=" + agentId;
|
||||||
String responseText = get(url, null);
|
String responseText = get(url, null);
|
||||||
JsonElement je = Streams.parse(new JsonReader(new StringReader(responseText)));
|
JsonElement je = Streams.parse(new JsonReader(new StringReader(responseText)));
|
||||||
JsonObject jo = je.getAsJsonObject();
|
JsonObject jo = je.getAsJsonObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user