企业号变成了企业微信
This commit is contained in:
parent
e197e3cd73
commit
01fa30f0da
@ -3,6 +3,7 @@ package com.foxinmy.weixin4j.qy;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.cache.CacheStorager;
|
||||
import com.foxinmy.weixin4j.cache.FileCacheStorager;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
@ -65,7 +66,7 @@ import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月19日
|
||||
* @since JDK 1.6
|
||||
* @see <a href="http://qydev.weixin.qq.com/wiki/index.php">api文档</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc">api文档</a>
|
||||
*/
|
||||
public class WeixinProxy {
|
||||
/**
|
||||
@ -151,8 +152,10 @@ public class WeixinProxy {
|
||||
* @param cacheStorager
|
||||
* token管理
|
||||
*/
|
||||
public WeixinProxy(WeixinAccount weixinAccount, CacheStorager<Token> cacheStorager) {
|
||||
this(weixinAccount, new WeixinTokenCreator(weixinAccount.getId(), weixinAccount.getSecret()), cacheStorager);
|
||||
public WeixinProxy(WeixinAccount weixinAccount,
|
||||
CacheStorager<Token> cacheStorager) {
|
||||
this(weixinAccount, new WeixinTokenCreator(weixinAccount.getId(),
|
||||
weixinAccount.getSecret()), cacheStorager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,9 +170,13 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi
|
||||
* @see WeixinSuiteProxy#getWeixinProxy(String, String)
|
||||
*/
|
||||
public WeixinProxy(PerTicketManager perTicketManager, TokenManager suiteTokenManager) {
|
||||
this(new WeixinAccount(perTicketManager.getThirdId(), perTicketManager.getThirdSecret()),
|
||||
new WeixinTokenSuiteCreator(perTicketManager, suiteTokenManager), perTicketManager.getCacheStorager());
|
||||
public WeixinProxy(PerTicketManager perTicketManager,
|
||||
TokenManager suiteTokenManager) {
|
||||
this(
|
||||
new WeixinAccount(perTicketManager.getThirdId(),
|
||||
perTicketManager.getThirdSecret()),
|
||||
new WeixinTokenSuiteCreator(perTicketManager, suiteTokenManager),
|
||||
perTicketManager.getCacheStorager());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,15 +187,18 @@ public class WeixinProxy {
|
||||
* @param tokenManager
|
||||
* token管理
|
||||
*/
|
||||
private WeixinProxy(WeixinAccount weixinAccount, TokenCreator tokenCreator, CacheStorager<Token> cacheStorager) {
|
||||
private WeixinProxy(WeixinAccount weixinAccount, TokenCreator tokenCreator,
|
||||
CacheStorager<Token> cacheStorager) {
|
||||
if (weixinAccount == null) {
|
||||
throw new IllegalArgumentException("weixinAccount must not be empty");
|
||||
throw new IllegalArgumentException(
|
||||
"weixinAccount must not be empty");
|
||||
}
|
||||
if (tokenCreator == null) {
|
||||
throw new IllegalArgumentException("tokenCreator must not be empty");
|
||||
}
|
||||
if (cacheStorager == null) {
|
||||
throw new IllegalArgumentException("cacheStorager must not be empty");
|
||||
throw new IllegalArgumentException(
|
||||
"cacheStorager must not be empty");
|
||||
}
|
||||
this.tokenManager = new TokenManager(tokenCreator, cacheStorager);
|
||||
this.weixinAccount = weixinAccount;
|
||||
@ -242,7 +252,8 @@ public class WeixinProxy {
|
||||
* @return
|
||||
*/
|
||||
public TokenManager getTicketManager(TicketType ticketType) {
|
||||
return new TokenManager(new WeixinTicketCreator(ticketType, this.tokenManager), cacheStorager);
|
||||
return new TokenManager(new WeixinTicketCreator(ticketType,
|
||||
this.tokenManager), cacheStorager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,17 +267,11 @@ public class WeixinProxy {
|
||||
* @param message
|
||||
* 消息对象
|
||||
* @return 如果对应用或收件人、部门、标签任何一个无权限,则本次发送失败;如果收件人、部门或标签不存在,发送仍然执行,但返回无效的部分
|
||||
* </br>
|
||||
* { "errcode": 0, "errmsg": "ok", "invaliduser": "UserID1",
|
||||
* </br> { "errcode": 0, "errmsg": "ok", "invaliduser": "UserID1",
|
||||
* "invalidparty":"PartyID1", "invalidtag":"TagID1" }
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.NotifyApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E">
|
||||
* 发送接口说明</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F">
|
||||
* 发送格式说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10167">发送接口说明</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.Text
|
||||
* @see com.foxinmy.weixin4j.tuple.Image
|
||||
* @see com.foxinmy.weixin4j.tuple.Voice
|
||||
@ -276,7 +281,8 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.tuple.MpNews
|
||||
* @see com.foxinmy.weixin4j.qy.model.IdParameter
|
||||
*/
|
||||
public IdParameter sendNotifyMessage(NotifyMessage message) throws WeixinException {
|
||||
public IdParameter sendNotifyMessage(NotifyMessage message)
|
||||
throws WeixinException {
|
||||
return notifyApi.sendNotifyMessage(message);
|
||||
}
|
||||
|
||||
@ -298,7 +304,8 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.message.CustomeMessage
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult sendCustomeMessage(CustomeMessage message) throws WeixinException {
|
||||
public ApiResult sendCustomeMessage(CustomeMessage message)
|
||||
throws WeixinException {
|
||||
return notifyApi.sendCustomeMessage(message);
|
||||
}
|
||||
|
||||
@ -329,12 +336,11 @@ public class WeixinProxy {
|
||||
* 菜单列表
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.MenuApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%88%9B%E5%BB%BA%E5%BA%94%E7%94%A8%E8%8F%9C%E5%8D%95">
|
||||
* 创建自定义菜单</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10786"> 创建自定义菜单</a>
|
||||
* @see com.foxinmy.weixin4j.model.Button
|
||||
*/
|
||||
public ApiResult createMenu(int agentid, List<Button> buttons) throws WeixinException {
|
||||
public ApiResult createMenu(int agentid, List<Button> buttons)
|
||||
throws WeixinException {
|
||||
return menuApi.createMenu(agentid, buttons);
|
||||
}
|
||||
|
||||
@ -346,9 +352,7 @@ public class WeixinProxy {
|
||||
* @return 菜单集合
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.MenuApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E8%8F%9C%E5%8D%95%E5%88%97%E8%A1%A8">
|
||||
* 查询菜单</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10787"> 查询菜单</a>
|
||||
* @see com.foxinmy.weixin4j.model.Button
|
||||
*/
|
||||
public List<Button> getMenu(int agentid) throws WeixinException {
|
||||
@ -362,9 +366,7 @@ public class WeixinProxy {
|
||||
* 应用ID
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.MenuApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%88%A0%E9%99%A4%E8%8F%9C%E5%8D%95">
|
||||
* 删除菜单</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10788"> 删除菜单</a>
|
||||
* @return 处理结果
|
||||
*/
|
||||
public ApiResult deleteMenu(int agentid) throws WeixinException {
|
||||
@ -386,7 +388,8 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String uploadImage(InputStream is, String fileName) throws WeixinException {
|
||||
public String uploadImage(InputStream is, String fileName)
|
||||
throws WeixinException {
|
||||
return mediaApi.uploadImage(is, fileName);
|
||||
}
|
||||
|
||||
@ -406,15 +409,14 @@ public class WeixinProxy {
|
||||
* @return 上传到微信服务器返回的媒体标识
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @see com.foxinmy.weixin4j.model.media.MediaUploadResult
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">
|
||||
* 上传临时素材文件说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10112"> 上传临时素材文件说明</a>
|
||||
* @see <a href=
|
||||
* "http://http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">
|
||||
* 上传永久素材文件说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MediaUploadResult uploadMedia(int agentid, InputStream is, String fileName) throws WeixinException {
|
||||
public MediaUploadResult uploadMedia(int agentid, InputStream is,
|
||||
String fileName) throws WeixinException {
|
||||
return mediaApi.uploadMedia(agentid, is, fileName);
|
||||
}
|
||||
|
||||
@ -428,15 +430,14 @@ public class WeixinProxy {
|
||||
* @return 媒体下载结果
|
||||
* @see com.foxinmy.weixin4j.model.media.MediaDownloadResult
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">
|
||||
* 获取临时媒体说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10115"> 获取临时媒体说明</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">
|
||||
* 获取永久媒体说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MediaDownloadResult downloadMedia(int agentid, String mediaId) throws WeixinException {
|
||||
public MediaDownloadResult downloadMedia(int agentid, String mediaId)
|
||||
throws WeixinException {
|
||||
return mediaApi.downloadMedia(agentid, mediaId);
|
||||
}
|
||||
|
||||
@ -459,7 +460,8 @@ public class WeixinProxy {
|
||||
* 上传永久媒体素材</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.MpArticle
|
||||
*/
|
||||
public String uploadMaterialArticle(int agentid, List<MpArticle> articles) throws WeixinException {
|
||||
public String uploadMaterialArticle(int agentid, List<MpArticle> articles)
|
||||
throws WeixinException {
|
||||
return mediaApi.uploadMaterialArticle(agentid, articles);
|
||||
}
|
||||
|
||||
@ -477,7 +479,8 @@ public class WeixinProxy {
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%88%A0%E9%99%A4%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">
|
||||
* 删除永久媒体素材</a>
|
||||
*/
|
||||
public ApiResult deleteMaterialMedia(int agentid, String mediaId) throws WeixinException {
|
||||
public ApiResult deleteMaterialMedia(int agentid, String mediaId)
|
||||
throws WeixinException {
|
||||
return mediaApi.deleteMaterialMedia(agentid, mediaId);
|
||||
}
|
||||
|
||||
@ -494,7 +497,8 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @see com.foxinmy.weixin4j.tuple.MpArticle
|
||||
*/
|
||||
public List<MpArticle> downloadArticle(int agentid, String mediaId) throws WeixinException {
|
||||
public List<MpArticle> downloadArticle(int agentid, String mediaId)
|
||||
throws WeixinException {
|
||||
return mediaApi.downloadArticle(agentid, mediaId);
|
||||
}
|
||||
|
||||
@ -515,7 +519,8 @@ public class WeixinProxy {
|
||||
* 修改永久媒体素材</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.MpArticle
|
||||
*/
|
||||
public String updateMaterialArticle(int agentid, String mediaId, List<MpArticle> articles) throws WeixinException {
|
||||
public String updateMaterialArticle(int agentid, String mediaId,
|
||||
List<MpArticle> articles) throws WeixinException {
|
||||
return mediaApi.updateMaterialArticle(agentid, mediaId, articles);
|
||||
}
|
||||
|
||||
@ -557,7 +562,8 @@ public class WeixinProxy {
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E5%88%97%E8%A1%A8">
|
||||
* 获取素材列表</a>
|
||||
*/
|
||||
public MediaRecord listMaterialMedia(int agentid, MediaType mediaType, Pageable pageable) throws WeixinException {
|
||||
public MediaRecord listMaterialMedia(int agentid, MediaType mediaType,
|
||||
Pageable pageable) throws WeixinException {
|
||||
return mediaApi.listMaterialMedia(agentid, mediaType, pageable);
|
||||
}
|
||||
|
||||
@ -573,7 +579,8 @@ public class WeixinProxy {
|
||||
* @see {@link #listMaterialMedia(int,MediaType, Pageable)}
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<MediaItem> listAllMaterialMedia(int agentid, MediaType mediaType) throws WeixinException {
|
||||
public List<MediaItem> listAllMaterialMedia(int agentid, MediaType mediaType)
|
||||
throws WeixinException {
|
||||
return mediaApi.listAllMaterialMedia(agentid, mediaType);
|
||||
}
|
||||
|
||||
@ -583,9 +590,7 @@ public class WeixinProxy {
|
||||
* @param party
|
||||
* 部门对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E5.88.9B.E5.BB.BA.E9.83.A8.E9.97.A8">
|
||||
* 创建部门说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10076"> 创建部门说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.PartyApi
|
||||
* @return 部门ID
|
||||
* @throws WeixinException
|
||||
@ -600,9 +605,7 @@ public class WeixinProxy {
|
||||
* @param party
|
||||
* 部门对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E6.9B.B4.E6.96.B0.E9.83.A8.E9.97.A8">
|
||||
* 更新部门说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10077"> 更新部门说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.PartyApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
@ -617,9 +620,7 @@ public class WeixinProxy {
|
||||
* @param partyId
|
||||
* 部门ID。获取指定部门ID下的子部门 传入0表示获取全部子部门
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E5.88.97.E8.A1.A8">
|
||||
* 获取部门列表</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10093"> 获取部门列表</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.PartyApi
|
||||
* @return 部门列表
|
||||
* @throws WeixinException
|
||||
@ -633,9 +634,7 @@ public class WeixinProxy {
|
||||
*
|
||||
* @param partyId
|
||||
* 部门ID
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E5.88.A0.E9.99.A4.E9.83.A8.E9.97.A8">
|
||||
* 删除部门说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10079"> 删除部门说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.PartyApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
@ -652,13 +651,12 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.MediaApi
|
||||
* @see com.foxinmy.weixin4j.qy.api.BatchApi
|
||||
* @see {@link #batchReplaceParty(String,Callback)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E9.80.9A.E8.AE.AF.E5.BD.95.E6.9B.B4.E6.96.B0">
|
||||
* 批量任务</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138"> 批量任务</a>
|
||||
* @return 上传后的mediaId
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchUploadParties(List<Party> parties) throws WeixinException {
|
||||
public String batchUploadParties(List<Party> parties)
|
||||
throws WeixinException {
|
||||
return mediaApi.batchUploadParties(parties);
|
||||
}
|
||||
|
||||
@ -668,9 +666,7 @@ public class WeixinProxy {
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.9B.E5.BB.BA.E6.88.90.E5.91.98">
|
||||
* 创建成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10018"> 创建成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
@ -687,14 +683,13 @@ public class WeixinProxy {
|
||||
* @param avatar
|
||||
* 头像文件 可为空
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.9B.E5.BB.BA.E6.88.90.E5.91.98">
|
||||
* 创建成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10018"> 创建成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult createUser(User user, InputStream avatar) throws WeixinException {
|
||||
public ApiResult createUser(User user, InputStream avatar)
|
||||
throws WeixinException {
|
||||
return userApi.createUser(user, avatar);
|
||||
}
|
||||
|
||||
@ -704,9 +699,7 @@ public class WeixinProxy {
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">
|
||||
* 更新成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10020"> 更新成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
@ -723,14 +716,13 @@ public class WeixinProxy {
|
||||
* @param avatar
|
||||
* 头像文件
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">
|
||||
* 更新成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10020"> 更新成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult updateUser(User user, InputStream avatar) throws WeixinException {
|
||||
public ApiResult updateUser(User user, InputStream avatar)
|
||||
throws WeixinException {
|
||||
return userApi.updateUser(user, avatar);
|
||||
}
|
||||
|
||||
@ -740,9 +732,7 @@ public class WeixinProxy {
|
||||
* @param userid
|
||||
* 成员唯一ID
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E8.8E.B7.E5.8F.96.E6.88.90.E5.91.98">
|
||||
* 获取成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10019"> 获取成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 成员对象
|
||||
* @throws WeixinException
|
||||
@ -761,11 +751,9 @@ public class WeixinProxy {
|
||||
* @return 成员对象
|
||||
* @see {@link #getUser(String)}
|
||||
* @see {@link #getUserIdByCode(String)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E8%8E%B7%E5%8F%96code">
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10028/根据code获取成员信息">
|
||||
* 企业获取code</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%A0%B9%E6%8D%AEcode%E8%8E%B7%E5%8F%96%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF">
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10028/根据code获取成员信息">
|
||||
* 根据code获取成员信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -794,15 +782,13 @@ public class WeixinProxy {
|
||||
*
|
||||
* @param code
|
||||
* 通过员工授权获取到的code,每次员工授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
|
||||
* @return 两个元素的数组 <font color="red">第一个元素为userId或者openId
|
||||
* 第二个元素为deviceId</font>
|
||||
* @return 换取结果
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=OAuth%E9%AA%8C%E8%AF%81%E6%8E%A5%E5%8F%A3">
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10028">
|
||||
* oauth授权获取用户信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String[] getUserIdByCode(String code) throws WeixinException {
|
||||
public JSONObject getUserIdByCode(String code) throws WeixinException {
|
||||
return userApi.getUserIdByCode(code);
|
||||
}
|
||||
|
||||
@ -818,15 +804,13 @@ public class WeixinProxy {
|
||||
* @param findDetail
|
||||
* 是否获取详细信息
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98">
|
||||
* 获取部门成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10061"> 获取部门成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 成员列表
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<User> listUser(int partyId, boolean fetchChild, UserStatus userStatus, boolean findDetail)
|
||||
throws WeixinException {
|
||||
public List<User> listUser(int partyId, boolean fetchChild,
|
||||
UserStatus userStatus, boolean findDetail) throws WeixinException {
|
||||
return userApi.listUser(partyId, fetchChild, userStatus, findDetail);
|
||||
}
|
||||
|
||||
@ -864,9 +848,7 @@ public class WeixinProxy {
|
||||
*
|
||||
* @param userid
|
||||
* 成员ID
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98">
|
||||
* 删除成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10030"> 删除成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
@ -880,14 +862,13 @@ public class WeixinProxy {
|
||||
*
|
||||
* @param userIds
|
||||
* 成员列表
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98"
|
||||
* >批量删除成员说明</a
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10060" >批量删除成员说明</a
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult batchDeleteUser(List<String> userIds) throws WeixinException {
|
||||
public ApiResult batchDeleteUser(List<String> userIds)
|
||||
throws WeixinException {
|
||||
return userApi.batchDeleteUser(userIds);
|
||||
}
|
||||
|
||||
@ -905,7 +886,8 @@ public class WeixinProxy {
|
||||
* 邀请成员关注说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public InviteType inviteUser(String userId, String tips) throws WeixinException {
|
||||
public InviteType inviteUser(String userId, String tips)
|
||||
throws WeixinException {
|
||||
return userApi.inviteUser(userId, tips);
|
||||
}
|
||||
|
||||
@ -916,9 +898,7 @@ public class WeixinProxy {
|
||||
* 成员ID
|
||||
* @return 调用结果
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%B3%E6%B3%A8%E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8">
|
||||
* 二次验证说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11378"> 二次验证说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult userAuthsucc(String userId) throws WeixinException {
|
||||
@ -929,12 +909,9 @@ public class WeixinProxy {
|
||||
* 创建标签(创建的标签属于管理组;默认为未加锁状态)
|
||||
*
|
||||
* @param tag
|
||||
* 标签对象;</br>
|
||||
* 标签名称,长度为1~64个字节,标签名不可与其他标签重名;</br>
|
||||
* 标签id,整型, 指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.9B.E5.BB.BA.E6.A0.87.E7.AD.BE">
|
||||
* 创建标签说明</a>
|
||||
* 标签对象;</br> 标签名称,长度为1~64个字节,标签名不可与其他标签重名;</br> 标签id,整型,
|
||||
* 指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10915"> 创建标签说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @return 标签ID
|
||||
* @throws WeixinException
|
||||
@ -948,9 +925,7 @@ public class WeixinProxy {
|
||||
*
|
||||
* @param tag
|
||||
* 标签信息
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E6.9B.B4.E6.96.B0.E6.A0.87.E7.AD.BE.E5.90.8D.E5.AD.97"
|
||||
* >更新标签说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10919" >更新标签说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.model.Tag
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @return 处理结果
|
||||
@ -966,9 +941,7 @@ public class WeixinProxy {
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @return 处理结果
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.A0.E9.99.A4.E6.A0.87.E7.AD.BE">
|
||||
* 删除标签说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10920"> 删除标签说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -979,9 +952,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 获取标签列表
|
||||
*
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E8.8E.B7.E5.8F.96.E6.A0.87.E7.AD.BE.E5.88.97.E8.A1.A8">
|
||||
* 获取标签列表说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10926"> 获取标签列表说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.model.Tag
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @return 标签列表
|
||||
@ -997,12 +968,10 @@ public class WeixinProxy {
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E8.8E.B7.E5.8F.96.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 获取标签成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10921"> 获取标签成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @return 成员列表<font color="red">Contacts#getUsers</font>和部门列表
|
||||
* <font color="red">Contacts#getPartyIds</font>
|
||||
* @return 成员列表<font color="red">Contacts#getUsers</font>和部门列表 <font
|
||||
* color="red">Contacts#getPartyIds</font>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public Contacts getTagUsers(int tagId) throws WeixinException {
|
||||
@ -1018,15 +987,14 @@ public class WeixinProxy {
|
||||
* 企业成员ID列表,注意:userlist、partylist不能同时为空
|
||||
* @param partyIds
|
||||
* 企业部门ID列表,注意:userlist、partylist不能同时为空
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.A2.9E.E5.8A.A0.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 新增标签成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10923"> 新增标签成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @see com.foxinmy.weixin4j.qy.model.IdParameter
|
||||
* @return 非法的userIds和partyIds
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public IdParameter addTagUsers(int tagId, List<String> userIds, List<Integer> partyIds) throws WeixinException {
|
||||
public IdParameter addTagUsers(int tagId, List<String> userIds,
|
||||
List<Integer> partyIds) throws WeixinException {
|
||||
return tagApi.addTagUsers(tagId, userIds, partyIds);
|
||||
}
|
||||
|
||||
@ -1039,15 +1007,14 @@ public class WeixinProxy {
|
||||
* 企业成员ID列表,注意:userlist、partylist不能同时为空
|
||||
* @param partyIds
|
||||
* 企业部门ID列表,注意:userlist、partylist不能同时为空
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.A0.E9.99.A4.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 删除标签成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10925"> 删除标签成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.TagApi
|
||||
* @see com.foxinmy.weixin4j.qy.model.IdParameter
|
||||
* @return 非法的userIds和partyIds
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public IdParameter deleteTagUsers(int tagId, List<String> userIds, List<Integer> partyIds) throws WeixinException {
|
||||
public IdParameter deleteTagUsers(int tagId, List<String> userIds,
|
||||
List<Integer> partyIds) throws WeixinException {
|
||||
return tagApi.deleteTagUsers(tagId, userIds, partyIds);
|
||||
}
|
||||
|
||||
@ -1073,9 +1040,7 @@ public class WeixinProxy {
|
||||
* @return 应用信息
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentInfo
|
||||
* @see com.foxinmy.weixin4j.qy.api.AgentApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%8F%B7%E5%BA%94%E7%94%A8">
|
||||
* 企业号应用的信息</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10087"> 企业号应用的信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public AgentInfo getAgent(int agentid) throws WeixinException {
|
||||
@ -1089,9 +1054,7 @@ public class WeixinProxy {
|
||||
* 设置参数
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentSetter
|
||||
* @see com.foxinmy.weixin4j.qy.api.AgentApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%AE%BE%E7%BD%AE%E4%BC%81%E4%B8%9A%E5%8F%B7%E5%BA%94%E7%94%A8">
|
||||
* 设置企业号信息</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10088"> 设置企业号信息</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -1104,9 +1067,7 @@ public class WeixinProxy {
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentOverview
|
||||
* @see com.foxinmy.weixin4j.qy.api.AgentApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E6%A6%82%E5%86%B5%E5%88%97%E8%A1%A8">
|
||||
* 获取应用概况</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11214"> 获取应用概况</a>
|
||||
* @return 应用概况列表
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -1132,7 +1093,8 @@ public class WeixinProxy {
|
||||
* 邀请成员关注</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchInviteUser(IdParameter parameter, Callback callback, String tips) throws WeixinException {
|
||||
public String batchInviteUser(IdParameter parameter, Callback callback,
|
||||
String tips) throws WeixinException {
|
||||
return batchApi.inviteUser(parameter, callback, tips);
|
||||
}
|
||||
|
||||
@ -1140,8 +1102,7 @@ public class WeixinProxy {
|
||||
* 批量更新成员,本接口以userid为主键,增量更新企业号通讯录成员。
|
||||
* <p>
|
||||
* 1.模板中的部门需填写部门ID,多个部门用分号分隔,部门ID必须为数字</br>
|
||||
* 2.文件中存在、通讯录中也存在的成员,更新成员在文件中指定的字段值 </br>
|
||||
* 3.文件中存在、通讯录中不存在的成员,执行添加操作</br>
|
||||
* 2.文件中存在、通讯录中也存在的成员,更新成员在文件中指定的字段值 </br> 3.文件中存在、通讯录中不存在的成员,执行添加操作</br>
|
||||
* 4.通讯录中存在、文件中不存在的成员,保持不变</br>
|
||||
* </p>
|
||||
*
|
||||
@ -1152,20 +1113,19 @@ public class WeixinProxy {
|
||||
* @return 异步任务id,最大长度为64字符
|
||||
* @see com.foxinmy.weixin4j.qy.model.Callback
|
||||
* @see com.foxinmy.weixin4j.qy.api.BatchApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E5.A2.9E.E9.87.8F.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138/增量更新成员">
|
||||
* 批量更新成员</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchSyncUser(String mediaId, Callback callback) throws WeixinException {
|
||||
public String batchSyncUser(String mediaId, Callback callback)
|
||||
throws WeixinException {
|
||||
return batchApi.syncUser(mediaId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量覆盖成员,本接口以userid为主键,全量覆盖企业号通讯录成员,任务完成后企业号通讯录成员与提交的文件完全保持一致。
|
||||
* <p>
|
||||
* 1.模板中的部门需填写部门ID,多个部门用分号分隔,部门ID必须为数字</br>
|
||||
* 2.文件中存在、通讯录中也存在的成员,完全以文件为准</br>
|
||||
* 1.模板中的部门需填写部门ID,多个部门用分号分隔,部门ID必须为数字</br> 2.文件中存在、通讯录中也存在的成员,完全以文件为准</br>
|
||||
* 3.文件中存在、通讯录中不存在的成员,执行添加操作</br>
|
||||
* 4.通讯录中存在、文件中不存在的成员,执行删除操作。出于安全考虑,如果需要删除的成员多于50人,
|
||||
* 且多于现有人数的20%以上,系统将中止导入并返回相应的错误码
|
||||
@ -1178,12 +1138,12 @@ public class WeixinProxy {
|
||||
* @return 异步任务id,最大长度为64字符
|
||||
* @see com.foxinmy.weixin4j.qy.model.Callback
|
||||
* @see com.foxinmy.weixin4j.qy.api.BatchApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E5.85.A8.E9.87.8F.E8.A6.86.E7.9B.96.E6.88.90.E5.91.98">
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138/全量覆盖成员">
|
||||
* 批量覆盖成员</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchReplaceUser(String mediaId, Callback callback) throws WeixinException {
|
||||
public String batchReplaceUser(String mediaId, Callback callback)
|
||||
throws WeixinException {
|
||||
return batchApi.replaceUser(mediaId, callback);
|
||||
}
|
||||
|
||||
@ -1196,9 +1156,7 @@ public class WeixinProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.BatchApi
|
||||
* @see {@link #batchSyncUser(String,Callback)}
|
||||
* @see {@link #batchReplaceUser(String,Callback)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E9.80.9A.E8.AE.AF.E5.BD.95.E6.9B.B4.E6.96.B0">
|
||||
* 批量任务</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138"> 批量任务</a>
|
||||
* @return 上传后的mediaId
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -1209,8 +1167,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 批量覆盖部门,本接口以partyid为键,全量覆盖企业号通讯录组织架构,任务完成后企业号通讯录组织架构与提交的文件完全保持一致。
|
||||
* <p>
|
||||
* 1.文件中存在、通讯录中也存在的部门,执行修改操作</br>
|
||||
* 2.文件中存在、通讯录中不存在的部门,执行添加操作</br>
|
||||
* 1.文件中存在、通讯录中也存在的部门,执行修改操作</br> 2.文件中存在、通讯录中不存在的部门,执行添加操作</br>
|
||||
* 3.文件中不存在、通讯录中存在的部门,当部门为空时,执行删除操作</br>
|
||||
* 4.CSV文件中,部门名称、部门ID、父部门ID为必填字段,部门ID必须为数字;排序为可选字段,置空或填0不修改排序
|
||||
* </p>
|
||||
@ -1222,12 +1179,12 @@ public class WeixinProxy {
|
||||
* @return 异步任务id,最大长度为64字符
|
||||
* @see com.foxinmy.weixin4j.qy.model.Callback
|
||||
* @see com.foxinmy.weixin4j.qy.api.BatchApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E5.85.A8.E9.87.8F.E8.A6.86.E7.9B.96.E9.83.A8.E9.97.A8">
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138/全量覆盖部门">
|
||||
* 批量覆盖部门</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String batchReplaceParty(String mediaId, Callback callback) throws WeixinException {
|
||||
public String batchReplaceParty(String mediaId, Callback callback)
|
||||
throws WeixinException {
|
||||
return batchApi.replaceParty(mediaId, callback);
|
||||
}
|
||||
|
||||
@ -1259,11 +1216,11 @@ public class WeixinProxy {
|
||||
* @return 结果数组 第一个元素为对应的openid 第二个元素则为应用的appid(如果有)
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=Userid%E4%B8%8Eopenid%E4%BA%92%E6%8D%A2%E6%8E%A5%E5%8F%A3">
|
||||
* userid转换成openid</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11279">
|
||||
* userid与openid互换</a>
|
||||
*/
|
||||
public String[] userid2openid(String userid, int agentid) throws WeixinException {
|
||||
public String[] userid2openid(String userid, int agentid)
|
||||
throws WeixinException {
|
||||
return userApi.userid2openid(userid, agentid);
|
||||
}
|
||||
|
||||
@ -1276,9 +1233,8 @@ public class WeixinProxy {
|
||||
* @return 该openid在企业号中对应的成员userid
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=Userid%E4%B8%8Eopenid%E4%BA%92%E6%8D%A2%E6%8E%A5%E5%8F%A3">
|
||||
* openid转换成userid</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11279">
|
||||
* userid与openid互换</a>
|
||||
*/
|
||||
public String openid2userid(String openid) throws WeixinException {
|
||||
return userApi.openid2userid(openid);
|
||||
@ -1337,7 +1293,8 @@ public class WeixinProxy {
|
||||
* 修改会话信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult updateChat(ChatInfo chatInfo, String operator, List<String> addUsers, List<String> deleteUsers)
|
||||
public ApiResult updateChat(ChatInfo chatInfo, String operator,
|
||||
List<String> addUsers, List<String> deleteUsers)
|
||||
throws WeixinException {
|
||||
return chatApi.updateChat(chatInfo, operator, addUsers, deleteUsers);
|
||||
}
|
||||
@ -1356,7 +1313,8 @@ public class WeixinProxy {
|
||||
* 退出会话</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult quitChat(String chatId, String operator) throws WeixinException {
|
||||
public ApiResult quitChat(String chatId, String operator)
|
||||
throws WeixinException {
|
||||
return chatApi.quitChat(chatId, operator);
|
||||
}
|
||||
|
||||
@ -1376,7 +1334,8 @@ public class WeixinProxy {
|
||||
* 清除会话未读状态</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult clearChatNotify(String targetId, String owner, ChatType chatType) throws WeixinException {
|
||||
public ApiResult clearChatNotify(String targetId, String owner,
|
||||
ChatType chatType) throws WeixinException {
|
||||
return chatApi.clearChatNotify(targetId, owner, chatType);
|
||||
}
|
||||
|
||||
@ -1394,7 +1353,8 @@ public class WeixinProxy {
|
||||
* @return 列表中不存在的成员,剩余合法成员会继续执行。
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<String> setChatMute(List<ChatMute> chatMutes) throws WeixinException {
|
||||
public List<String> setChatMute(List<ChatMute> chatMutes)
|
||||
throws WeixinException {
|
||||
return chatApi.setChatMute(chatMutes);
|
||||
}
|
||||
|
||||
@ -1411,7 +1371,8 @@ public class WeixinProxy {
|
||||
* 发送消息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult sendChatMessage(ChatMessage message) throws WeixinException {
|
||||
public ApiResult sendChatMessage(ChatMessage message)
|
||||
throws WeixinException {
|
||||
return chatApi.sendChatMessage(message);
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,7 @@ import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
* @date 2015年6月22日
|
||||
* @since JDK 1.6
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%88%E6%9D%83">
|
||||
* 企业号第三方应用</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10968"> 企业号第三方应用</a>
|
||||
*/
|
||||
public class WeixinSuiteProxy {
|
||||
|
||||
@ -169,8 +167,7 @@ public class WeixinSuiteProxy {
|
||||
* 套件ID
|
||||
* @param suiteTicket
|
||||
* 套件ticket内容
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%9B%9E%E8%B0%83%E5%8D%8F%E8%AE%AE#.E6.8E.A8.E9.80.81suite_ticket.E5.8D.8F.E8.AE.AE">
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10982/推送suite_ticket">
|
||||
* 推送suite_ticket协议</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -213,9 +210,7 @@ public class WeixinSuiteProxy {
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi#getTicketManager()
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi#getPreCodeManager()
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi#exchangeAuthInfo(String)
|
||||
* @see <a href="http://qydev.weixin.qq.com/wiki/index.php?title
|
||||
* =%E4%BC%81%E4%B8%9A%E5%8F%B7%E7%AE%A1%E7%90%86%E5%91%98%E6%
|
||||
* 8E%88%E6%9D%83%E5%BA%94%E7%94%A8">企业号第三方应用套件授权</a>
|
||||
* @see <a href="http://work.weixin.qq.com/api/doc#10974">企业号第三方应用套件授权</a>
|
||||
* @return 请求授权的URL
|
||||
* @throws WeixinException
|
||||
*/
|
||||
|
||||
@ -22,8 +22,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年3月16日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E4%BC%81%E4%B8%9A%E5%8F%B7%E5%BA%94%E7%94%A8">管理应用接口说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10025">管理应用接口说明</a>
|
||||
*/
|
||||
public class AgentApi extends QyApi {
|
||||
private final TokenManager tokenManager;
|
||||
@ -39,15 +38,14 @@ public class AgentApi extends QyApi {
|
||||
* 授权方应用id
|
||||
* @return 应用信息
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentInfo
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%8F%B7%E5%BA%94%E7%94%A8">企业号应用的信息</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10087">企业号应用的信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public AgentInfo getAgent(int agentid) throws WeixinException {
|
||||
String agent_get_uri = getRequestUri("agent_get_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.get(String.format(agent_get_uri,
|
||||
token.getAccessToken(), agentid));
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
agent_get_uri, token.getAccessToken(), agentid));
|
||||
JSONObject jsonObj = response.getAsJson();
|
||||
AgentInfo agent = JSON.toJavaObject(jsonObj, AgentInfo.class);
|
||||
agent.setAllowUsers(JSON.parseArray(
|
||||
@ -67,8 +65,7 @@ public class AgentApi extends QyApi {
|
||||
* @param agentSet
|
||||
* 设置信息
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentSetter
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E8%AE%BE%E7%BD%AE%E4%BC%81%E4%B8%9A%E5%8F%B7%E5%BA%94%E7%94%A8">设置企业号信息</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10088">设置企业号信息</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -101,16 +98,15 @@ public class AgentApi extends QyApi {
|
||||
* 获取应用概况列表
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentOverview
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E6%A6%82%E5%86%B5%E5%88%97%E8%A1%A8">获取应用概况</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#11214">获取应用概况</a>
|
||||
* @return 应用概况列表
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<AgentOverview> listAgentOverview() throws WeixinException {
|
||||
String agent_list_uri = getRequestUri("agent_list_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.get(String.format(agent_list_uri,
|
||||
token.getAccessToken()));
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
agent_list_uri, token.getAccessToken()));
|
||||
|
||||
return JSON.parseArray(response.getAsJson().getString("agentlist"),
|
||||
AgentOverview.class);
|
||||
|
||||
@ -20,8 +20,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年3月30日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3">批量任务</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10138">批量任务</a>
|
||||
*/
|
||||
public class BatchApi extends QyApi {
|
||||
|
||||
@ -77,8 +76,7 @@ public class BatchApi extends QyApi {
|
||||
* @return 异步任务id,最大长度为64字符
|
||||
* @see {@link MediaApi#batchUploadUsers(java.util.List)}
|
||||
* @see com.foxinmy.weixin4j.qy.model.Callback
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E5.A2.9E.E9.87.8F.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">批量更新成员</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10138/增量更新成员">批量更新成员</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String syncUser(String mediaId, Callback callback)
|
||||
@ -115,8 +113,7 @@ public class BatchApi extends QyApi {
|
||||
* @return 异步任务id,最大长度为64字符
|
||||
* @see {@link MediaApi#batchUploadUsers(java.util.List)}
|
||||
* @see com.foxinmy.weixin4j.qy.model.Callback
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E5.85.A8.E9.87.8F.E8.A6.86.E7.9B.96.E6.88.90.E5.91.98">批量覆盖成员</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10138/全量覆盖成员">批量覆盖成员</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String replaceUser(String mediaId, Callback callback)
|
||||
@ -140,8 +137,7 @@ public class BatchApi extends QyApi {
|
||||
* @return 异步任务id,最大长度为64字符
|
||||
* @see {@link MediaApi#batchUploadParties(java.util.List)}
|
||||
* @see com.foxinmy.weixin4j.qy.model.Callback
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E5.85.A8.E9.87.8F.E8.A6.86.E7.9B.96.E9.83.A8.E9.97.A8">批量覆盖部门</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10138/全量覆盖部门">批量覆盖部门</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String replaceParty(String mediaId, Callback callback)
|
||||
|
||||
@ -54,8 +54,6 @@ import com.foxinmy.weixin4j.util.StringUtil;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年9月25日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">管理素材文件</a>
|
||||
* @see com.foxinmy.weixin4j.type.MediaType
|
||||
*/
|
||||
public class MediaApi extends QyApi {
|
||||
@ -113,8 +111,7 @@ public class MediaApi extends QyApi {
|
||||
* 文件名
|
||||
* @return 上传到微信服务器返回的媒体标识
|
||||
* @see com.foxinmy.weixin4j.model.media.MediaUploadResult
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">上传临时素材文件说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10112">上传临时素材文件说明</a>
|
||||
* @see <a href=
|
||||
* "http://http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">上传永久素材文件说明</a>
|
||||
* @throws WeixinException
|
||||
@ -192,8 +189,7 @@ public class MediaApi extends QyApi {
|
||||
* 媒体ID
|
||||
* @return 媒体下载结果
|
||||
* @see com.foxinmy.weixin4j.model.media.MediaDownloadResult
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">获取临时媒体说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10115">获取临时媒体说明</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">获取永久媒体说明</a>
|
||||
* @throws WeixinException
|
||||
@ -436,8 +432,7 @@ public class MediaApi extends QyApi {
|
||||
* 成员列表
|
||||
* @see {@link BatchApi#syncUser(String,Callback)}
|
||||
* @see {@link BatchApi#replaceUser(String,Callback)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E9.80.9A.E8.AE.AF.E5.BD.95.E6.9B.B4.E6.96.B0">批量任务</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138">批量任务</a>
|
||||
* @return 上传后的mediaId
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -451,8 +446,7 @@ public class MediaApi extends QyApi {
|
||||
* @param parties
|
||||
* 部门列表
|
||||
* @see {@link BatchApi#replaceParty(String,Callback)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E9.80.9A.E8.AE.AF.E5.BD.95.E6.9B.B4.E6.96.B0">批量任务</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10138">批量任务</a>
|
||||
* @return 上传后的mediaId
|
||||
* @throws WeixinException
|
||||
*/
|
||||
|
||||
@ -44,26 +44,31 @@ public class MenuApi extends QyApi {
|
||||
* @param buttons
|
||||
* 菜单列表
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%88%9B%E5%BB%BA%E5%BA%94%E7%94%A8%E8%8F%9C%E5%8D%95">
|
||||
* 创建自定义菜单</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10786"> 创建自定义菜单</a>
|
||||
* @see com.foxinmy.weixin4j.model.Button
|
||||
*/
|
||||
public ApiResult createMenu(int agentid, List<Button> buttons) throws WeixinException {
|
||||
public ApiResult createMenu(int agentid, List<Button> buttons)
|
||||
throws WeixinException {
|
||||
String menu_create_uri = getRequestUri("menu_create_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("button", buttons);
|
||||
WeixinResponse response = weixinExecutor.post(String.format(menu_create_uri, token.getAccessToken(), agentid),
|
||||
JSON.toJSONString(obj, new NameFilter() {
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(menu_create_uri, token.getAccessToken(),
|
||||
agentid), JSON.toJSONString(obj, new NameFilter() {
|
||||
@Override
|
||||
public String process(Object object, String name, Object value) {
|
||||
if (object instanceof Button && name.equals("content")
|
||||
&& StringUtil.isNotBlank(((Button) object).getType())) {
|
||||
ButtonType buttonType = ButtonType.valueOf(((Button) object).getType());
|
||||
public String process(Object object, String name,
|
||||
Object value) {
|
||||
if (object instanceof Button
|
||||
&& name.equals("content")
|
||||
&& StringUtil.isNotBlank(((Button) object)
|
||||
.getType())) {
|
||||
ButtonType buttonType = ButtonType
|
||||
.valueOf(((Button) object).getType());
|
||||
if (ButtonType.view == buttonType) {
|
||||
return "url";
|
||||
} else if (ButtonType.media_id == buttonType || ButtonType.view_limited == buttonType) {
|
||||
} else if (ButtonType.media_id == buttonType
|
||||
|| ButtonType.view_limited == buttonType) {
|
||||
return "media_id";
|
||||
} else {
|
||||
return "key";
|
||||
@ -83,15 +88,14 @@ public class MenuApi extends QyApi {
|
||||
* 应用ID
|
||||
* @return 菜单集合
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E8%8F%9C%E5%8D%95%E5%88%97%E8%A1%A8">
|
||||
* 查询菜单</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10787"> 查询菜单</a>
|
||||
* @see com.foxinmy.weixin4j.model.Button
|
||||
*/
|
||||
public List<Button> getMenu(int agentid) throws WeixinException {
|
||||
String menu_get_uri = getRequestUri("menu_get_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.get(String.format(menu_get_uri, token.getAccessToken(), agentid));
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
menu_get_uri, token.getAccessToken(), agentid));
|
||||
JSONArray buttons = response.getAsJson().getJSONArray("button");
|
||||
List<Button> buttonList = new ArrayList<Button>(buttons.size());
|
||||
ParseProcess processor = new ExtraProcessor() {
|
||||
@ -101,7 +105,8 @@ public class MenuApi extends QyApi {
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < buttons.size(); i++) {
|
||||
buttonList.add(JSON.parseObject(buttons.getString(i), Button.class, processor));
|
||||
buttonList.add(JSON.parseObject(buttons.getString(i), Button.class,
|
||||
processor));
|
||||
}
|
||||
return buttonList;
|
||||
}
|
||||
@ -112,15 +117,14 @@ public class MenuApi extends QyApi {
|
||||
* @param agentid
|
||||
* 应用ID
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%88%A0%E9%99%A4%E8%8F%9C%E5%8D%95">
|
||||
* 删除菜单</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10788"> 删除菜单</a>
|
||||
* @return 处理结果
|
||||
*/
|
||||
public ApiResult deleteMenu(int agentid) throws WeixinException {
|
||||
String menu_delete_uri = getRequestUri("menu_delete_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.get(String.format(menu_delete_uri, token.getAccessToken(), agentid));
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
menu_delete_uri, token.getAccessToken(), agentid));
|
||||
|
||||
return response.getAsResult();
|
||||
}
|
||||
|
||||
@ -26,10 +26,7 @@ import com.foxinmy.weixin4j.tuple.NotifyTuple;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月21日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E">发送接口说明</a>
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F">发送格式说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10167">发送接口说明</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.Text
|
||||
* @see com.foxinmy.weixin4j.tuple.Image
|
||||
* @see com.foxinmy.weixin4j.tuple.Voice
|
||||
@ -56,14 +53,11 @@ public class NotifyApi extends QyApi {
|
||||
*
|
||||
* @param message
|
||||
* 消息对象
|
||||
* @return 如果无权限或收件人不存在,则本次发送失败;如果未关注,发送仍然执行。两种情况下均返回无效的部分(注:由于userid不区分大小写,返回的列表都统一转为小写</br> { "errcode":
|
||||
* 0, "errmsg": "ok", "invaliduser": "UserID1",
|
||||
* "invalidparty":"PartyID1", "invalidtag":"TagID1" }
|
||||
* @return 如果无权限或收件人不存在,则本次发送失败;如果未关注,发送仍然执行。两种情况下均返回无效的部分(注:由于userid不区分大小写,
|
||||
* 返回的列表都统一转为小写</br> { "errcode": 0, "errmsg": "ok", "invaliduser":
|
||||
* "UserID1", "invalidparty":"PartyID1", "invalidtag":"TagID1" }
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E">发送接口说明</a>
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F">发送格式说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10167">发送接口说明</a>
|
||||
* @see com.foxinmy.weixin4j.tuple.Text
|
||||
* @see com.foxinmy.weixin4j.tuple.Image
|
||||
* @see com.foxinmy.weixin4j.tuple.Voice
|
||||
|
||||
@ -14,15 +14,10 @@ import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月11日
|
||||
* @since JDK 1.6
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10028"> 企业号用户身份授权说明</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=OAuth%E9%AA%8C%E8%AF%81%E6%8E%A5%E5%8F%A3">
|
||||
* 企业号用户身份授权说明</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E5%8F%B7%E7%99%BB%E5%BD%95%E6%8E%88%E6%9D%83">
|
||||
* 企业号第三方提供商授权说明</a>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%88%E6%9D%83">
|
||||
* 企业号第三方套件应用授权说明</a>
|
||||
* "http://work.weixin.qq.com/api/doc#11791/服务商的凭证">企业号第三方提供商授权说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10974"> 企业号第三方套件应用授权说明</a>
|
||||
*/
|
||||
public class OauthApi extends QyApi {
|
||||
private final WeixinAccount account;
|
||||
@ -55,7 +50,8 @@ public class OauthApi extends QyApi {
|
||||
public String getUserAuthorizationURL() {
|
||||
String redirectUri = Weixin4jConfigUtil
|
||||
.getValue("user.oauth.redirect.uri");
|
||||
return getUserAuthorizationURL(redirectUri, "state");
|
||||
return getUserAuthorizationURL(redirectUri, "snsapi_base", "state",
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,19 +59,26 @@ public class OauthApi extends QyApi {
|
||||
*
|
||||
* @param redirectUri
|
||||
* 重定向地址
|
||||
* @param scope
|
||||
* 应用授权作用域。 snsapi_base:静默授权,可获取成员的基础信息;</br>
|
||||
* snsapi_userinfo:静默授权,可获取成员的详细信息,但不包含手机、邮箱;</br>
|
||||
* snsapi_privateinfo:手动授权,可获取成员的详细信息,包含手机、邮箱。</br>
|
||||
* @param state
|
||||
* 用于保持请求和回调的状态
|
||||
* @param agentId
|
||||
* 企业应用的id。 当scope是snsapi_userinfo或snsapi_privateinfo时,该参数必填。
|
||||
* 注意redirect_uri的域名必须与该应用的可信域名一致。
|
||||
* @return 请求授权的URL
|
||||
* @see UserApi#getOUserInfoByCode(String, String)
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81">
|
||||
* 企业号用户身份授权</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10028">企业号用户身份授权</a>
|
||||
*/
|
||||
public String getUserAuthorizationURL(String redirectUri, String state) {
|
||||
public String getUserAuthorizationURL(String redirectUri, String scope,
|
||||
String state, Integer agentId) {
|
||||
String oauth_uri = getRequestUri("user_oauth_uri");
|
||||
try {
|
||||
return String.format(oauth_uri, account.getId(),
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()), state);
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()), scope,
|
||||
state, agentId != null ? agentId.intValue() : "");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
;
|
||||
}
|
||||
|
||||
@ -19,8 +19,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @date 2014年11月18日
|
||||
* @since JDK 1.6
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8">管理部门说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10076">管理部门说明</a>
|
||||
*/
|
||||
public class PartyApi extends QyApi {
|
||||
private final TokenManager tokenManager;
|
||||
@ -35,8 +34,7 @@ public class PartyApi extends QyApi {
|
||||
* @param party
|
||||
* 部门对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E5.88.9B.E5.BB.BA.E9.83.A8.E9.97.A8">创建部门说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10076">创建部门说明</a>
|
||||
* @return 部门ID
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -62,8 +60,7 @@ public class PartyApi extends QyApi {
|
||||
* @param party
|
||||
* 部门对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E6.9B.B4.E6.96.B0.E9.83.A8.E9.97.A8">更新部门说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10077">更新部门说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -92,8 +89,7 @@ public class PartyApi extends QyApi {
|
||||
* @param partId
|
||||
* 部门ID。获取指定部门ID下的子部门 传入0表示获取全部子部门
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E5.88.97.E8.A1.A8">获取部门列表</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10093">获取部门列表</a>
|
||||
* @return 部门列表
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -114,8 +110,7 @@ public class PartyApi extends QyApi {
|
||||
*
|
||||
* @param partId
|
||||
* 部门ID
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E5.88.A0.E9.99.A4.E9.83.A8.E9.97.A8">删除部门说明</a>
|
||||
* @see <a href="https://work.weixin.qq.com/api/doc#10079">删除部门说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
|
||||
@ -12,7 +12,7 @@ import com.foxinmy.weixin4j.api.BaseApi;
|
||||
* @date 2014年11月18日
|
||||
* @since JDK 1.6
|
||||
* @see com.foxinmy.weixin4j.api.BaseApi
|
||||
* @see <a href="http://qydev.weixin.qq.com/wiki/index.php">api文档</a>
|
||||
* @see <a href="http://work.weixin.qq.com/api/doc#10012">api文档</a>
|
||||
*/
|
||||
public class QyApi extends BaseApi {
|
||||
|
||||
|
||||
@ -25,8 +25,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%88%E6%9D%83">第三方应用授权</a>
|
||||
* @see <a href="http://work.weixin.qq.com/api/doc#10968">第三方应用授权</a>
|
||||
*/
|
||||
public class SuiteApi extends QyApi {
|
||||
/**
|
||||
@ -49,9 +48,10 @@ public class SuiteApi extends QyApi {
|
||||
*/
|
||||
public SuiteApi(TicketManager ticketManager) {
|
||||
this.ticketManager = ticketManager;
|
||||
this.tokenManager = new TokenManager(new WeixinSuiteTokenCreator(ticketManager),
|
||||
ticketManager.getCacheStorager());
|
||||
this.preCodeManager = new TokenManager(new WeixinSuitePreCodeCreator(tokenManager, ticketManager.getThirdId()),
|
||||
this.tokenManager = new TokenManager(new WeixinSuiteTokenCreator(
|
||||
ticketManager), ticketManager.getCacheStorager());
|
||||
this.preCodeManager = new TokenManager(new WeixinSuitePreCodeCreator(
|
||||
tokenManager, ticketManager.getThirdId()),
|
||||
ticketManager.getCacheStorager());
|
||||
}
|
||||
|
||||
@ -90,7 +90,8 @@ public class SuiteApi extends QyApi {
|
||||
* @return 应用套件的preticket管理
|
||||
*/
|
||||
public PerTicketManager getPerTicketManager(String authCorpId) {
|
||||
return new PerTicketManager(authCorpId, ticketManager.getThirdId(), ticketManager.getThirdSecret(),
|
||||
return new PerTicketManager(authCorpId, ticketManager.getThirdId(),
|
||||
ticketManager.getThirdSecret(),
|
||||
ticketManager.getCacheStorager());
|
||||
}
|
||||
|
||||
@ -102,7 +103,8 @@ public class SuiteApi extends QyApi {
|
||||
* @return 企业号token
|
||||
*/
|
||||
public TokenManager getPerTokenManager(String authCorpId) {
|
||||
return new TokenManager(new WeixinTokenSuiteCreator(getPerTicketManager(authCorpId), tokenManager),
|
||||
return new TokenManager(new WeixinTokenSuiteCreator(
|
||||
getPerTicketManager(authCorpId), tokenManager),
|
||||
ticketManager.getCacheStorager());
|
||||
}
|
||||
|
||||
@ -124,8 +126,9 @@ public class SuiteApi extends QyApi {
|
||||
JSONObject appid = new JSONObject();
|
||||
appid.put("appid", appids);
|
||||
para.put("session_info", appid);
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(suite_set_session_uri, tokenManager.getAccessToken()), para.toJSONString());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(suite_set_session_uri,
|
||||
tokenManager.getAccessToken()), para.toJSONString());
|
||||
return response.getAsResult();
|
||||
}
|
||||
|
||||
@ -138,25 +141,28 @@ public class SuiteApi extends QyApi {
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.model.OUserInfo
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E4.BC.81.E4.B8.9A.E5.8F.B7.E7.9A.84.E6.B0.B8.E4.B9.85.E6.8E.88.E6.9D.83.E7.A0.81"
|
||||
* >获取企业号的永久授权码</a>
|
||||
* "https://work.weixin.qq.com/api/doc#10975/获取企业永久授权码">获取企业号的永久授权码</a>
|
||||
*/
|
||||
public OUserInfo exchangeAuthInfo(String authCode) throws WeixinException {
|
||||
String suite_get_permanent_uri = getRequestUri("suite_get_permanent_uri");
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("suite_id", ticketManager.getThirdId());
|
||||
obj.put("auth_code", authCode);
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(suite_get_permanent_uri, tokenManager.getAccessToken()), obj.toJSONString());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(suite_get_permanent_uri,
|
||||
tokenManager.getAccessToken()), obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
obj.put("corp_info", obj.remove("auth_corp_info"));
|
||||
obj.put("user_info", obj.remove("auth_user_info"));
|
||||
OUserInfo oInfo = JSON.toJavaObject(obj, OUserInfo.class);
|
||||
// 微信授权企业号的永久授权码
|
||||
PerTicketManager perTicketManager = getPerTicketManager(oInfo.getCorpInfo().getCorpId());
|
||||
PerTicketManager perTicketManager = getPerTicketManager(oInfo
|
||||
.getCorpInfo().getCorpId());
|
||||
// 缓存微信企业号的access_token
|
||||
TokenCreator tokenCreator = new WeixinTokenSuiteCreator(perTicketManager, tokenManager);
|
||||
Token token = new Token(obj.getString("access_token"), obj.getLongValue("expires_in") * 1000l);
|
||||
TokenCreator tokenCreator = new WeixinTokenSuiteCreator(
|
||||
perTicketManager, tokenManager);
|
||||
Token token = new Token(obj.getString("access_token"),
|
||||
obj.getLongValue("expires_in") * 1000l);
|
||||
ticketManager.getCacheStorager().caching(tokenCreator.key(), token);
|
||||
// 缓存微信企业号的永久授权码
|
||||
perTicketManager.cachingTicket(obj.getString("permanent_code"));
|
||||
@ -172,16 +178,18 @@ public class SuiteApi extends QyApi {
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.qy.model.OUserInfo
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E4.BC.81.E4.B8.9A.E5.8F.B7.E7.9A.84.E6.8E.88.E6.9D.83.E4.BF.A1.E6.81.AF">获取企业号的授权信息</a>
|
||||
* "https://work.weixin.qq.com/api/doc#10975/获取企业授权信息">获取企业号的授权信息</a>
|
||||
*/
|
||||
public OUserInfo getAuthInfo(String authCorpId) throws WeixinException {
|
||||
String suite_get_authinfo_uri = getRequestUri("suite_get_authinfo_uri");
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("suite_id", ticketManager.getThirdId());
|
||||
obj.put("auth_corpid", authCorpId);
|
||||
obj.put("permanent_code", getPerTicketManager(authCorpId).getAccessTicket());
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(suite_get_authinfo_uri, tokenManager.getAccessToken()), obj.toJSONString());
|
||||
obj.put("permanent_code", getPerTicketManager(authCorpId)
|
||||
.getAccessTicket());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(suite_get_authinfo_uri,
|
||||
tokenManager.getAccessToken()), obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
obj.put("corp_info", obj.remove("auth_corp_info"));
|
||||
obj.put("user_info", obj.remove("auth_user_info"));
|
||||
@ -198,24 +206,31 @@ public class SuiteApi extends QyApi {
|
||||
* @return 应用信息
|
||||
* @see com.foxinmy.weixin4j.qy.model.AgentInfo
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E4.BC.81.E4.B8.9A.E5.8F.B7.E5.BA.94.E7.94.A8">获取企业号应用</a>
|
||||
* "https://work.weixin.qq.com/api/doc#10975/获取企业授权信息">获取企业号应用</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public AgentInfo getAgent(String authCorpId, int agentid) throws WeixinException {
|
||||
public AgentInfo getAgent(String authCorpId, int agentid)
|
||||
throws WeixinException {
|
||||
String suite_get_agent_uri = getRequestUri("suite_get_agent_uri");
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("suite_id", ticketManager.getThirdId());
|
||||
obj.put("auth_corpid", authCorpId);
|
||||
obj.put("permanent_code", getPerTicketManager(authCorpId).getAccessTicket());
|
||||
obj.put("permanent_code", getPerTicketManager(authCorpId)
|
||||
.getAccessTicket());
|
||||
obj.put("agentid", agentid);
|
||||
WeixinResponse response = weixinExecutor.post(String.format(suite_get_agent_uri, tokenManager.getAccessToken()),
|
||||
obj.toJSONString());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(suite_get_agent_uri,
|
||||
tokenManager.getAccessToken()), obj.toJSONString());
|
||||
JSONObject jsonObj = response.getAsJson();
|
||||
AgentInfo agent = JSON.toJavaObject(jsonObj, AgentInfo.class);
|
||||
agent.setAllowUsers(JSON.parseArray(jsonObj.getJSONObject("allow_userinfos").getString("user"), User.class));
|
||||
agent.setAllowPartys(
|
||||
JSON.parseArray(jsonObj.getJSONObject("allow_partys").getString("partyid"), Integer.class));
|
||||
agent.setAllowTags(JSON.parseArray(jsonObj.getJSONObject("allow_tags").getString("tagid"), Integer.class));
|
||||
agent.setAllowUsers(JSON.parseArray(
|
||||
jsonObj.getJSONObject("allow_userinfos").getString("user"),
|
||||
User.class));
|
||||
agent.setAllowPartys(JSON.parseArray(
|
||||
jsonObj.getJSONObject("allow_partys").getString("partyid"),
|
||||
Integer.class));
|
||||
agent.setAllowTags(JSON.parseArray(jsonObj.getJSONObject("allow_tags")
|
||||
.getString("tagid"), Integer.class));
|
||||
return agent;
|
||||
}
|
||||
|
||||
@ -232,14 +247,18 @@ public class SuiteApi extends QyApi {
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult setAgent(String authCorpId, AgentSetter agentSet) throws WeixinException {
|
||||
public ApiResult setAgent(String authCorpId, AgentSetter agentSet)
|
||||
throws WeixinException {
|
||||
String suite_set_agent_uri = getRequestUri("suite_set_agent_uri");
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("suite_id", ticketManager.getThirdId());
|
||||
obj.put("auth_corpid", authCorpId);
|
||||
obj.put("permanent_code", getPerTicketManager(authCorpId).getAccessTicket());
|
||||
obj.put("permanent_code", getPerTicketManager(authCorpId)
|
||||
.getAccessTicket());
|
||||
obj.put("agent", agentSet);
|
||||
WeixinResponse response = weixinExecutor.post(String.format(suite_set_agent_uri, tokenManager.getAccessToken()),
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(suite_set_agent_uri,
|
||||
tokenManager.getAccessToken()),
|
||||
JSON.toJSONString(obj, AgentApi.typeFilter));
|
||||
return response.getAsResult();
|
||||
}
|
||||
|
||||
@ -22,9 +22,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月19日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE">
|
||||
* 管理标签</a>
|
||||
* @see <a href="http://work.weixin.qq.com/api/doc#10915">管理标签</a>
|
||||
*/
|
||||
public class TagApi extends QyApi {
|
||||
private final TokenManager tokenManager;
|
||||
@ -39,9 +37,7 @@ public class TagApi extends QyApi {
|
||||
* @param tag
|
||||
* 标签对象;</br> 标签名称,长度限制为32个字(汉字或英文字母),标签名不可与其他标签重名。</br> 标签id,整型,
|
||||
* 指定此参数时新增的标签会生成对应的标签id,不指定时则以目前最大的id自增。
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.9B.E5.BB.BA.E6.A0.87.E7.AD.BE">
|
||||
* 创建标签说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10915"> 创建标签说明</a>
|
||||
* @return 标签ID
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -63,9 +59,7 @@ public class TagApi extends QyApi {
|
||||
*
|
||||
* @param tag
|
||||
* 标签信息
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E6.9B.B4.E6.96.B0.E6.A0.87.E7.AD.BE.E5.90.8D.E5.AD.97"
|
||||
* >更新标签说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10919" >更新标签说明</a>
|
||||
* @return 处理结果
|
||||
* @see com.foxinmy.weixin4j.qy.model.Tag
|
||||
* @throws WeixinException
|
||||
@ -85,9 +79,7 @@ public class TagApi extends QyApi {
|
||||
* @param tagId
|
||||
* 标签ID
|
||||
* @return 处理结果
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.A0.E9.99.A4.E6.A0.87.E7.AD.BE">
|
||||
* 删除标签说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10920"> 删除标签说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult deleteTag(int tagId) throws WeixinException {
|
||||
@ -101,9 +93,7 @@ public class TagApi extends QyApi {
|
||||
/**
|
||||
* 获取标签列表
|
||||
*
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E8.8E.B7.E5.8F.96.E6.A0.87.E7.AD.BE.E5.88.97.E8.A1.A8">
|
||||
* 获取标签列表说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10926"> 获取标签列表说明</a>
|
||||
* @return 标签列表
|
||||
* @see com.foxinmy.weixin4j.qy.model.Tag
|
||||
* @throws WeixinException
|
||||
@ -124,9 +114,7 @@ public class TagApi extends QyApi {
|
||||
* 标签ID
|
||||
* @see com.foxinmy.weixin4j.qy.model.Contacts
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E8.8E.B7.E5.8F.96.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 获取标签成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10921"> 获取标签成员说明</a>
|
||||
* @return 成员列表<font color="red">Contacts#getUsers</font>和部门列表<font
|
||||
* color="red">Contacts#getPartyIds</font>
|
||||
* @throws WeixinException
|
||||
@ -154,9 +142,7 @@ public class TagApi extends QyApi {
|
||||
* 企业成员ID列表,注意:userlist、partylist不能同时为空,单次请求长度不超过1000
|
||||
* @param partyIds
|
||||
* 企业部门ID列表,注意:userlist、partylist不能同时为空,单次请求长度不超过100
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.A2.9E.E5.8A.A0.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 新增标签成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10923"> 新增标签成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.model.IdParameter
|
||||
* @return 非法的userIds和partyIds
|
||||
* @throws WeixinException
|
||||
@ -176,9 +162,7 @@ public class TagApi extends QyApi {
|
||||
* 企业成员ID列表,注意:userlist、partylist不能同时为空
|
||||
* @param partyIds
|
||||
* 企业部门ID列表,注意:userlist、partylist不能同时为空
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.A0.E9.99.A4.E6.A0.87.E7.AD.BE.E6.88.90.E5.91.98">
|
||||
* 删除标签成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10925"> 删除标签成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.model.IdParameter
|
||||
* @return 非法的userIds和partyIds
|
||||
* @throws WeixinException
|
||||
|
||||
@ -28,9 +28,7 @@ import com.foxinmy.weixin4j.util.StringUtil;
|
||||
* @date 2014年11月19日
|
||||
* @since JDK 1.6
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98">
|
||||
* 管理成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10018">管理成员说明</a>
|
||||
*/
|
||||
public class UserApi extends QyApi {
|
||||
private final MediaApi mediaApi;
|
||||
@ -49,9 +47,7 @@ public class UserApi extends QyApi {
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.9B.E5.BB.BA.E6.88.90.E5.91.98">
|
||||
* 创建成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10018"> 创建成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -68,9 +64,7 @@ public class UserApi extends QyApi {
|
||||
* @param avatar
|
||||
* 头像文件 可为空
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.9B.E5.BB.BA.E6.88.90.E5.91.98">
|
||||
* 创建成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10018"> 创建成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -86,9 +80,7 @@ public class UserApi extends QyApi {
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">
|
||||
* 更新成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10020"> 更新成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -105,9 +97,7 @@ public class UserApi extends QyApi {
|
||||
* @param avatar
|
||||
* 头像文件
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">
|
||||
* 更新成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10020"> 更新成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -147,9 +137,7 @@ public class UserApi extends QyApi {
|
||||
* @param userid
|
||||
* 成员唯一ID
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E8.8E.B7.E5.8F.96.E6.88.90.E5.91.98">
|
||||
* 获取成员说明</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10019">获取成员说明</a>
|
||||
* @return 成员对象
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -177,17 +165,35 @@ public class UserApi extends QyApi {
|
||||
* @return 成员对象
|
||||
* @see {@link #getUser(String)}
|
||||
* @see {@link #getUserIdByCode(String)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=OAuth%E9%AA%8C%E8%AF%81%E6%8E%A5%E5%8F%A3">
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10028/根据code获取成员信息">
|
||||
* oauth授权获取用户信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public User getUserByCode(String code) throws WeixinException {
|
||||
String[] userIds = getUserIdByCode(code);
|
||||
if (Boolean.parseBoolean(userIds[2])) {
|
||||
return getUser(openid2userid(userIds[0]));
|
||||
JSONObject result = getUserIdByCode(code);
|
||||
if (result.containsKey("user_ticket")) {
|
||||
String user_ticket_detail_uri = getRequestUri("user_ticket_detail_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(user_ticket_detail_uri,
|
||||
token.getAccessToken()),
|
||||
String.format("{\"user_ticket\":\"%s\"}",
|
||||
result.getString("user_ticket")));
|
||||
JSONObject obj = response.getAsJson();
|
||||
Object attrs = obj.remove("extattr");
|
||||
User user = JSON.toJavaObject(obj, User.class);
|
||||
if (attrs != null) {
|
||||
user.setExtattr(JSON.parseArray(
|
||||
((JSONObject) attrs).getString("attrs"),
|
||||
NameValue.class));
|
||||
}
|
||||
return user;
|
||||
} else {
|
||||
return getUser(userIds[0]);
|
||||
String userId = result.getString("UserId");
|
||||
if (StringUtil.isBlank(userId)) {
|
||||
userId = openid2userid(result.getString("OpenId"));
|
||||
}
|
||||
return getUser(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,27 +202,17 @@ public class UserApi extends QyApi {
|
||||
*
|
||||
* @param code
|
||||
* 通过员工授权获取到的code,每次员工授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期
|
||||
* @return 两个元素的数组 <font color="red">第一个元素为userId或者openId
|
||||
* 第二个元素为deviceId</font>
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=OAuth%E9%AA%8C%E8%AF%81%E6%8E%A5%E5%8F%A3">
|
||||
* @return 换取结果
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10028">
|
||||
* oauth授权获取用户信息</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String[] getUserIdByCode(String code) throws WeixinException {
|
||||
public JSONObject getUserIdByCode(String code) throws WeixinException {
|
||||
String user_getid_uri = getRequestUri("user_getid_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
user_getid_uri, token.getAccessToken(), code));
|
||||
JSONObject result = response.getAsJson();
|
||||
String userId = result.getString("UserId");
|
||||
boolean need2 = false;
|
||||
if (StringUtil.isBlank(userId)) {
|
||||
userId = result.getString("OpenId");
|
||||
need2 = true;
|
||||
}
|
||||
return new String[] { userId, result.getString("DeviceId"),
|
||||
Boolean.toString(need2) };
|
||||
return response.getAsJson();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,9 +248,7 @@ public class UserApi extends QyApi {
|
||||
* @param findDetail
|
||||
* 是否获取详细信息
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98">
|
||||
* 获取部门成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10061"> 获取部门成员说明</a>
|
||||
* @return 成员列表
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -334,9 +328,7 @@ public class UserApi extends QyApi {
|
||||
*
|
||||
* @param userid
|
||||
* 成员ID
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98">
|
||||
* 删除成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10030"> 删除成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -353,9 +345,7 @@ public class UserApi extends QyApi {
|
||||
*
|
||||
* @param userIds
|
||||
* 成员列表
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98"
|
||||
* >批量删除成员说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10060" >批量删除成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
@ -377,9 +367,7 @@ public class UserApi extends QyApi {
|
||||
* @param userid
|
||||
* 成员ID
|
||||
* @return 调用结果
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%B3%E6%B3%A8%E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8">
|
||||
* 二次验证说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11378"> 二次验证说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult authsucc(String userId) throws WeixinException {
|
||||
@ -433,9 +421,8 @@ public class UserApi extends QyApi {
|
||||
* 需要发送红包的应用ID,若只是使用微信支付和企业转账,则无需该参数 传入0或负数则忽略
|
||||
* @return 结果数组 第一个元素为对应的openid 第二个元素则为应用的appid(如果有)
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=Userid%E4%B8%8Eopenid%E4%BA%92%E6%8D%A2%E6%8E%A5%E5%8F%A3">
|
||||
* userid转换成openid</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11279">
|
||||
* userid与openid互换</a>
|
||||
*/
|
||||
public String[] userid2openid(String userid, int agentid)
|
||||
throws WeixinException {
|
||||
@ -460,9 +447,8 @@ public class UserApi extends QyApi {
|
||||
* 在使用微信支付、微信红包和企业转账之后,返回结果的openid
|
||||
* @return 该openid在企业号中对应的成员userid
|
||||
* @throws WeixinException
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=Userid%E4%B8%8Eopenid%E4%BA%92%E6%8D%A2%E6%8E%A5%E5%8F%A3">
|
||||
* openid转换成userid</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#11279">
|
||||
* userid与openid互换</a>
|
||||
*/
|
||||
public String openid2userid(String openid) throws WeixinException {
|
||||
String openid2userid_uri = getRequestUri("openid2userid_uri");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# api\u9996\u9875
|
||||
# http://qydev.weixin.qq.com/wiki/index.php
|
||||
# https://work.weixin.qq.com/api/doc
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
api_base_url=https://qyapi.weixin.qq.com/cgi-bin
|
||||
@ -21,6 +21,8 @@ user_update_uri={api_base_url}/user/update?access_token=%s
|
||||
user_get_uri={api_base_url}/user/get?access_token=%s&userid=%s
|
||||
# code\u83b7\u53d6\u6210\u5458\u4fe1\u606f
|
||||
user_getid_uri={api_base_url}/user/getuserinfo?access_token=%s&code=%s
|
||||
# code->ticket\u83b7\u53d6\u6210\u5458\u4fe1\u606f
|
||||
user_ticket_detail_uri={api_base_url}/user/getuserdetail?access_token=%s
|
||||
# \u83b7\u53d6\u90e8\u95e8\u6210\u5458
|
||||
user_slist_uri={api_base_url}/user/simplelist?access_token=%s&department_id=%d&fetch_child=%d&status=%d
|
||||
# \u83b7\u53d6\u90e8\u95e8\u6210\u5458(\u8be6\u60c5)
|
||||
@ -87,7 +89,9 @@ batch_replaceparty.cvs={"header":"\u90e8\u95e8\u540d\u79f0,\u90e8\u95e8ID,\u7236
|
||||
batch_getresult_uri={api_base_url}/batch/getresult?access_token=%s&jobid=%s
|
||||
|
||||
# \u7528\u6237\u8eab\u4efdoauth\u6388\u6743
|
||||
user_oauth_uri=https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect
|
||||
user_oauth_uri=https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s&agentid=%s#wechat_redirect
|
||||
# \u4f7f\u7528user_ticket\u83b7\u53d6\u6210\u5458\u8be6\u60c5
|
||||
user_oauth_userdetail_uri={api_base_url}/user/getuserdetail?access_token=%s
|
||||
# \u6210\u5458\u767b\u5f55\u7b2c\u4e09\u65b9oauth\u6388\u6743
|
||||
user_thirdoauth_uri=https://qy.weixin.qq.com/cgi-bin/loginpage?corp_id=%s&redirect_uri=%s&state=%s&usertype=%s
|
||||
# \u4f01\u4e1a\u53f7\u6210\u5458\u767b\u5f55\u7b2c\u4e09\u65b9\u4fe1\u606f
|
||||
|
||||
@ -17,8 +17,6 @@ import com.foxinmy.weixin4j.tuple.NotifyTuple;
|
||||
* @see com.foxinmy.weixin4j.tuple.Voice
|
||||
* @see com.foxinmy.weixin4j.tuple.Video
|
||||
* @see com.foxinmy.weixin4j.tuple.File
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%9C%8D%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E">客服消息</a>
|
||||
*/
|
||||
public class CustomeMessage implements Serializable {
|
||||
|
||||
|
||||
@ -20,8 +20,6 @@ import com.foxinmy.weixin4j.tuple.NotifyTuple;
|
||||
* @see com.foxinmy.weixin4j.tuple.File
|
||||
* @see com.foxinmy.weixin4j.tuple.News
|
||||
* @see com.foxinmy.weixin4j.tuple.MpNews
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F">消息说明</a>
|
||||
*/
|
||||
public class NotifyMessage implements Serializable {
|
||||
|
||||
@ -51,7 +49,8 @@ public class NotifyMessage implements Serializable {
|
||||
this(agentid, tuple, IdParameter.get(), false);
|
||||
}
|
||||
|
||||
public NotifyMessage(int agentId, NotifyTuple tuple, IdParameter target, boolean isSafe) {
|
||||
public NotifyMessage(int agentId, NotifyTuple tuple, IdParameter target,
|
||||
boolean isSafe) {
|
||||
this.agentId = agentId;
|
||||
this.safe = isSafe ? 1 : 0;
|
||||
this.tuple = tuple;
|
||||
@ -84,6 +83,7 @@ public class NotifyMessage implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NotifyMessage [agentId=" + agentId + ", safe=" + safe + ", tuple=" + tuple + ", target=" + target + "]";
|
||||
return "NotifyMessage [agentId=" + agentId + ", safe=" + safe
|
||||
+ ", tuple=" + tuple + ", target=" + target + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,6 @@ import com.foxinmy.weixin4j.qy.type.ReportLocationType;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年3月16日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%AE%BE%E7%BD%AE%E4%BC%81%E4%B8%9A%E5%8F%B7%E5%BA%94%E7%94%A8">设置企业号应用</a>
|
||||
*/
|
||||
public class AgentSetter implements Serializable {
|
||||
private static final long serialVersionUID = 5420335232308079801L;
|
||||
|
||||
@ -11,8 +11,6 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月18日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8">管理部门说明</a>
|
||||
*/
|
||||
public class Party implements Serializable {
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
/**
|
||||
* 权限信息
|
||||
*
|
||||
* @className Privilege
|
||||
* @className PrivilegeInfo
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年3月28日
|
||||
* @since JDK 1.6
|
||||
|
||||
@ -3,7 +3,7 @@ package com.foxinmy.weixin4j.qy.model;
|
||||
/**
|
||||
* 权限级别
|
||||
*
|
||||
* @className Privilege
|
||||
* @className PrivilegeLevel
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年3月28日
|
||||
* @since JDK 1.6
|
||||
|
||||
@ -16,8 +16,6 @@ import com.foxinmy.weixin4j.util.NameValue;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月19日
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98">管理成员说明</a>
|
||||
*/
|
||||
public class User implements Serializable {
|
||||
|
||||
|
||||
@ -13,9 +13,6 @@ import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年11月18日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "https://qy.weixin.qq.com/cgi-bin/home?lang=zh_CN&token=685923034#setting"
|
||||
* >企业号设置</a>
|
||||
*/
|
||||
public class WeixinQyAccount extends WeixinAccount {
|
||||
|
||||
@ -72,8 +69,8 @@ public class WeixinQyAccount extends WeixinAccount {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeixinQyAccount [" + super.toString() + ", suites="
|
||||
+ suites + ", providerSecret=" + providerSecret
|
||||
+ ", chatSecret=" + chatSecret + "]";
|
||||
return "WeixinQyAccount [" + super.toString() + ", suites=" + suites
|
||||
+ ", providerSecret=" + providerSecret + ", chatSecret="
|
||||
+ chatSecret + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,8 +15,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E9.A2.84.E6.8E.88.E6.9D.83.E7.A0.81">
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10975/获取预授权码">
|
||||
* 获取应用套件预授权码</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
@ -32,7 +31,8 @@ public class WeixinSuitePreCodeCreator extends TokenCreator {
|
||||
* @param suiteId
|
||||
* 应用套件ID
|
||||
*/
|
||||
public WeixinSuitePreCodeCreator(TokenManager suiteTokenManager, String suiteId) {
|
||||
public WeixinSuitePreCodeCreator(TokenManager suiteTokenManager,
|
||||
String suiteId) {
|
||||
this.suiteTokenManager = suiteTokenManager;
|
||||
this.suiteId = suiteId;
|
||||
}
|
||||
@ -50,9 +50,11 @@ public class WeixinSuitePreCodeCreator extends TokenCreator {
|
||||
@Override
|
||||
public Token create() throws WeixinException {
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(URLConsts.SUITE_PRE_CODE_URL, suiteTokenManager.getAccessToken()),
|
||||
String.format(URLConsts.SUITE_PRE_CODE_URL,
|
||||
suiteTokenManager.getAccessToken()),
|
||||
String.format("{\"suite_id\":\"%s\"}", suiteId));
|
||||
JSONObject result = response.getAsJson();
|
||||
return new Token(result.getString("pre_auth_code"), result.getLongValue("expires_in") * 1000l);
|
||||
return new Token(result.getString("pre_auth_code"),
|
||||
result.getLongValue("expires_in") * 1000l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,8 +15,7 @@ import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E5.BA.94.E7.94.A8.E5.A5.97.E4.BB.B6.E4.BB.A4.E7.89.8C">获取应用套件凭证</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10975/获取应用套件凭证">获取应用套件凭证</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinSuiteTokenCreator extends TokenCreator {
|
||||
@ -48,8 +47,10 @@ public class WeixinSuiteTokenCreator extends TokenCreator {
|
||||
obj.put("suite_id", ticketManager.getThirdId());
|
||||
obj.put("suite_secret", ticketManager.getThirdSecret());
|
||||
obj.put("suite_ticket", ticketManager.getAccessTicket());
|
||||
WeixinResponse response = weixinExecutor.post(URLConsts.SUITE_TOKEN_URL, obj.toJSONString());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
URLConsts.SUITE_TOKEN_URL, obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
return new Token(obj.getString("suite_access_token"), obj.getLongValue("expires_in") * 1000l);
|
||||
return new Token(obj.getString("suite_access_token"),
|
||||
obj.getLongValue("expires_in") * 1000l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,8 +16,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月17日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E#.E8.8E.B7.E5.8F.96.E4.BC.81.E4.B8.9A.E5.8F.B7access_token">
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#10975/获取企业永久授权码">
|
||||
* 获取企业号access_token</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
@ -33,14 +32,16 @@ public class WeixinTokenSuiteCreator extends TokenCreator {
|
||||
* @param suiteTokenManager
|
||||
* 第三方套件凭证token
|
||||
*/
|
||||
public WeixinTokenSuiteCreator(PerTicketManager perTicketManager, TokenManager suiteTokenManager) {
|
||||
public WeixinTokenSuiteCreator(PerTicketManager perTicketManager,
|
||||
TokenManager suiteTokenManager) {
|
||||
this.perTicketManager = perTicketManager;
|
||||
this.suiteTokenManager = suiteTokenManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return String.format("qy_token_suite_%s_%s", perTicketManager.getThirdId(), perTicketManager.getAuthAppId());
|
||||
return String.format("qy_token_suite_%s_%s",
|
||||
perTicketManager.getThirdId(), perTicketManager.getAuthAppId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,8 +56,10 @@ public class WeixinTokenSuiteCreator extends TokenCreator {
|
||||
obj.put("auth_corpid", perTicketManager.getAuthAppId());
|
||||
obj.put("permanent_code", perTicketManager.getAccessTicket());
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(URLConsts.TOKEN_SUITE_URL, suiteTokenManager.getAccessToken()), obj.toJSONString());
|
||||
.post(String.format(URLConsts.TOKEN_SUITE_URL,
|
||||
suiteTokenManager.getAccessToken()), obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
return new Token(obj.getString("access_token"), obj.getLongValue("expires_in") * 1000l);
|
||||
return new Token(obj.getString("access_token"),
|
||||
obj.getLongValue("expires_in") * 1000l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,7 @@ import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E6%8F%90%E4%BE%9B%E5%95%86%E5%87%AD%E8%AF%81">
|
||||
* 获取应用提供商凭证</a>
|
||||
* @see <a href= "http://work.weixin.qq.com/api/doc#11791/服务商的凭证">服务商的凭证</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinProviderTokenCreator extends TokenCreator {
|
||||
@ -51,8 +49,10 @@ public class WeixinProviderTokenCreator extends TokenCreator {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("corpid", corpid);
|
||||
obj.put("provider_secret", providersecret);
|
||||
WeixinResponse response = weixinExecutor.post(URLConsts.PROVIDER_TOKEN_URL, obj.toJSONString());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
URLConsts.PROVIDER_TOKEN_URL, obj.toJSONString());
|
||||
obj = response.getAsJson();
|
||||
return new Token(obj.getString("provider_access_token"), obj.getLongValue("expires_in") * 1000l);
|
||||
return new Token(obj.getString("provider_access_token"),
|
||||
obj.getLongValue("expires_in") * 1000l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,9 +16,7 @@ import com.foxinmy.weixin4j.type.TicketType;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年12月25日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BE%AE%E4%BF%A1JS-SDK%E6%8E%A5%E5%8F%A3#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95"
|
||||
* >JSTICKET</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10029/附录1-JS-SDK使用权限签名算法">JSTICKET</a>
|
||||
*/
|
||||
public class WeixinTicketCreator extends TokenCreator {
|
||||
|
||||
@ -31,7 +29,8 @@ public class WeixinTicketCreator extends TokenCreator {
|
||||
* @param weixinTokenManager
|
||||
* <font color="red">企业号的access_token</font>
|
||||
*/
|
||||
public WeixinTicketCreator(TicketType ticketType, TokenManager weixinTokenManager) {
|
||||
public WeixinTicketCreator(TicketType ticketType,
|
||||
TokenManager weixinTokenManager) {
|
||||
this.ticketType = ticketType;
|
||||
this.weixinTokenManager = weixinTokenManager;
|
||||
}
|
||||
@ -50,14 +49,17 @@ public class WeixinTicketCreator extends TokenCreator {
|
||||
public Token create() throws WeixinException {
|
||||
WeixinResponse response = null;
|
||||
if (ticketType == TicketType.jsapi) {
|
||||
response = weixinExecutor
|
||||
.get(String.format(URLConsts.JS_TICKET_URL, weixinTokenManager.getCache().getAccessToken()));
|
||||
response = weixinExecutor.get(String.format(
|
||||
URLConsts.JS_TICKET_URL, weixinTokenManager.getCache()
|
||||
.getAccessToken()));
|
||||
} else {
|
||||
response = weixinExecutor.get(String.format(URLConsts.SUITE_TICKET_URL,
|
||||
weixinTokenManager.getCache().getAccessToken(), ticketType.name()));
|
||||
response = weixinExecutor.get(String.format(
|
||||
URLConsts.SUITE_TICKET_URL, weixinTokenManager.getCache()
|
||||
.getAccessToken(), ticketType.name()));
|
||||
}
|
||||
JSONObject result = response.getAsJson();
|
||||
return new Token(result.getString("ticket"), result.getLong("expires_in") * 1000l).pushExtra("group_id",
|
||||
return new Token(result.getString("ticket"),
|
||||
result.getLong("expires_in") * 1000l).pushExtra("group_id",
|
||||
result.getString("group_id"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,7 @@ import com.foxinmy.weixin4j.token.TokenCreator;
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年1月10日
|
||||
* @since JDK 1.6
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%BB%E5%8A%A8%E8%B0%83%E7%94%A8">
|
||||
* 微信企业号获取token说明</a>
|
||||
* @see <a href= "https://work.weixin.qq.com/api/doc#10013"> 微信企业号获取token说明</a>
|
||||
* @see com.foxinmy.weixin4j.model.Token
|
||||
*/
|
||||
public class WeixinTokenCreator extends TokenCreator {
|
||||
@ -48,9 +46,11 @@ public class WeixinTokenCreator extends TokenCreator {
|
||||
|
||||
@Override
|
||||
public Token create() throws WeixinException {
|
||||
String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, corpid, corpsecret);
|
||||
String tokenUrl = String.format(URLConsts.ASSESS_TOKEN_URL, corpid,
|
||||
corpsecret);
|
||||
WeixinResponse response = weixinExecutor.get(tokenUrl);
|
||||
JSONObject result = response.getAsJson();
|
||||
return new Token(result.getString("access_token"), result.getLongValue("expires_in") * 1000l);
|
||||
return new Token(result.getString("access_token"),
|
||||
result.getLongValue("expires_in") * 1000l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public final class URLConsts {
|
||||
/**
|
||||
* 应用套件oauth授权
|
||||
*/
|
||||
public static final String SUITE_OAUTH_URL = "https://qy.weixin.qq.com/cgi-bin/loginpage?suite_id=%s&pre_auth_code=%s&redirect_uri=%s&state=%s";
|
||||
public static final String SUITE_OAUTH_URL = "https://open.work.weixin.qq.com/3rdapp/install?suite_id=%s&pre_auth_code=%s&redirect_uri=%s&state=%s";
|
||||
/**
|
||||
* 企业号获取ticket的url
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user