public interface WxCpService
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
checkSignature(String msgSignature,
String timestamp,
String nonce,
String data)
验证推送过来的消息的正确性
详情请见: http://mp.weixin.qq.com/wiki/index.php?
|
WxJsapiSignature |
createJsapiSignature(String url)
创建调用jsapi时所需要的签名
详情请见:http://qydev.weixin.qq.com/wiki/index.php?
|
Integer |
departCreate(WxCpDepart depart)
|
void |
departDelete(Integer departId)
|
List<WxCpDepart> |
departGet()
已过时。
|
List<WxCpUser> |
departGetUsers(Integer departId,
Boolean fetchChild,
Integer status)
|
void |
departUpdate(WxCpDepart group)
|
<T,E> T |
execute(RequestExecutor<T,E> executor,
String uri,
E data)
Service没有实现某个API的时候,可以用这个,
比
get(java.lang.String, java.lang.String)和post(java.lang.String, java.lang.String)方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 |
String |
get(String url,
String queryParam)
当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
|
String |
getAccessToken()
获取access_token, 不强制刷新access_token
|
String |
getAccessToken(boolean forceRefresh)
获取access_token,本方法线程安全
且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限
另:本service的所有方法都会在access_token过期是调用此方法
程序员在非必要情况下尽量不要主动调用此方法
详情请见: http://mp.weixin.qq.com/wiki/index.php?
|
String[] |
getCallbackIp()
获取微信服务器的ip段
http://qydev.weixin.qq.com/wiki/index.php?
|
WxCpDepartmentService |
getDepartmentService()
获取部门相关接口的服务类对象
|
String |
getJsapiTicket()
获得jsapi_ticket,不强制刷新jsapi_ticket
|
String |
getJsapiTicket(boolean forceRefresh)
获得jsapi_ticket
获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
详情请见:http://qydev.weixin.qq.com/wiki/index.php?
|
WxCpMediaService |
getMediaService()
获取媒体相关接口的服务类对象
|
WxCpMenuService |
getMenuService()
获取菜单相关接口的服务类对象
|
WxCpOAuth2Service |
getOauth2Service()
获取Oauth2相关接口的服务类对象
|
RequestHttp |
getRequestHttp()
http请求对象
|
WxSession |
getSession(String id)
获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
|
WxSession |
getSession(String id,
boolean create)
获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
|
WxCpTagService |
getTagService()
获取标签相关接口的服务类对象
|
String |
getTaskResult(String joinId)
获取异步任务结果
|
WxCpUserService |
getUserService()
获取用户相关接口的服务类对象
|
WxCpConfigStorage |
getWxCpConfigStorage()
获取WxMpConfigStorage 对象
|
void |
initHttp()
初始化http请求对象
|
int |
invite(String userId,
String inviteTips)
邀请成员关注
http://qydev.weixin.qq.com/wiki/index.php?
|
File |
mediaDownload(String mediaId)
已过时。
|
WxMediaUploadResult |
mediaUpload(String mediaType,
File file)
|
WxMediaUploadResult |
mediaUpload(String mediaType,
String fileType,
InputStream inputStream)
|
void |
menuCreate(Integer agentId,
WxMenu menu)
|
void |
menuCreate(WxMenu menu)
已过时。
|
void |
menuDelete()
已过时。
请使用
WxCpMenuService.delete() } |
void |
menuDelete(Integer agentId)
已过时。
|
WxMenu |
menuGet()
已过时。
|
WxMenu |
menuGet(Integer agentId)
已过时。
|
WxCpMessageSendResult |
messageSend(WxCpMessage message)
发送消息
详情请见: http://qydev.weixin.qq.com/wiki/index.php?
|
String |
oauth2buildAuthorizationUrl(String state)
|
String |
oauth2buildAuthorizationUrl(String redirectUri,
String state)
|
String[] |
oauth2getUserInfo(Integer agentId,
String code)
|
String[] |
oauth2getUserInfo(String code)
|
String |
post(String url,
String postData)
当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
|
String |
replaceParty(String mediaId)
上传部门列表覆盖企业号上的部门信息
|
String |
replaceUser(String mediaId)
上传用户列表覆盖企业号上的用户信息
|
void |
setDepartmentService(WxCpDepartmentService departmentService) |
void |
setMaxRetryTimes(int maxRetryTimes)
设置当微信系统响应系统繁忙时,最大重试次数
默认:5次
|
void |
setMediaService(WxCpMediaService mediaService) |
void |
setMenuService(WxCpMenuService menuService) |
void |
setOauth2Service(WxCpOAuth2Service oauth2Service) |
void |
setRetrySleepMillis(int retrySleepMillis)
设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
默认:1000ms
|
void |
setSessionManager(WxSessionManager sessionManager)
设置WxSessionManager,只有当需要使用个性化的WxSessionManager的时候才需要调用此方法,
WxCpService默认使用的是
StandardSessionManager
|
void |
setTagService(WxCpTagService tagService) |
void |
setUserService(WxCpUserService userService) |
void |
setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider)
注入
WxCpConfigStorage 的实现 |
void |
tagAddUsers(String tagId,
List<String> userIds,
List<String> partyIds)
|
String |
tagCreate(String tagName)
已过时。
|
void |
tagDelete(String tagId)
已过时。
|
List<WxCpTag> |
tagGet()
已过时。
|
List<WxCpUser> |
tagGetUsers(String tagId)
|
void |
tagRemoveUsers(String tagId,
List<String> userIds)
|
void |
tagUpdate(String tagId,
String tagName)
|
void |
userAuthenticated(String userId)
已过时。
|
void |
userCreate(WxCpUser user)
已过时。
|
void |
userDelete(String userid)
已过时。
|
void |
userDelete(String[] userids)
已过时。
|
WxCpUser |
userGet(String userid)
已过时。
|
List<WxCpUser> |
userList(Integer departId,
Boolean fetchChild,
Integer status)
|
void |
userUpdate(WxCpUser user)
已过时。
|
boolean checkSignature(String msgSignature, String timestamp, String nonce, String data)
验证推送过来的消息的正确性 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=验证消息真实性
msgSignature - 消息签名timestamp - 时间戳nonce - 随机数data - 微信传输过来的数据,有可能是echoStr,有可能是xml消息String getAccessToken() throws WxErrorException
WxErrorExceptiongetAccessToken(boolean)String getAccessToken(boolean forceRefresh) throws WxErrorException
获取access_token,本方法线程安全 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限 另:本service的所有方法都会在access_token过期是调用此方法 程序员在非必要情况下尽量不要主动调用此方法 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token
forceRefresh - 强制刷新WxErrorExceptionString getJsapiTicket() throws WxErrorException
WxErrorExceptiongetJsapiTicket(boolean)String getJsapiTicket(boolean forceRefresh) throws WxErrorException
获得jsapi_ticket 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.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
forceRefresh - 强制刷新WxErrorExceptionWxJsapiSignature createJsapiSignature(String url) throws WxErrorException
创建调用jsapi时所需要的签名 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.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
url - urlWxErrorException@Deprecated void menuCreate(WxMenu menu) throws WxErrorException
WxCpMenuService.create(WxMenu)WxErrorException@Deprecated void menuCreate(Integer agentId, WxMenu menu) throws WxErrorException
WxErrorException@Deprecated void menuDelete() throws WxErrorException
WxCpMenuService.delete() }WxErrorException@Deprecated void menuDelete(Integer agentId) throws WxErrorException
WxCpMenuService.delete(Integer)WxErrorException@Deprecated WxMenu menuGet() throws WxErrorException
WxCpMenuService.get()WxErrorException@Deprecated WxMenu menuGet(Integer agentId) throws WxErrorException
WxCpMenuService.get(Integer)WxErrorExceptionWxCpMessageSendResult messageSend(WxCpMessage message) throws WxErrorException
发送消息 详情请见: 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
message - 要发送的消息对象WxErrorException@Deprecated Integer departCreate(WxCpDepart depart) throws WxErrorException
WxErrorException@Deprecated void departUpdate(WxCpDepart group) throws WxErrorException
WxErrorException@Deprecated void departDelete(Integer departId) throws WxErrorException
WxErrorException@Deprecated List<WxCpDepart> departGet() throws WxErrorException
WxCpDepartmentService.listAll()WxErrorException@Deprecated WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException
@Deprecated WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException
WxErrorException@Deprecated File mediaDownload(String mediaId) throws WxErrorException
WxCpMediaService.download(String)WxErrorException@Deprecated void userAuthenticated(String userId) throws WxErrorException
WxCpUserService.authenticate(String)WxErrorException@Deprecated void userCreate(WxCpUser user) throws WxErrorException
WxCpUserService.create(WxCpUser)WxErrorException@Deprecated void userUpdate(WxCpUser user) throws WxErrorException
WxCpUserService.update(WxCpUser)WxErrorException@Deprecated void userDelete(String userid) throws WxErrorException
WxCpUserService.delete(String...)WxErrorException@Deprecated void userDelete(String[] userids) throws WxErrorException
WxCpUserService.delete(String...)WxErrorException@Deprecated WxCpUser userGet(String userid) throws WxErrorException
WxCpUserService.getById(String)WxErrorException@Deprecated List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException
WxErrorException@Deprecated List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException
WxErrorException@Deprecated String tagCreate(String tagName) throws WxErrorException
WxCpTagService.create(String)WxErrorException@Deprecated void tagUpdate(String tagId, String tagName) throws WxErrorException
WxErrorException@Deprecated void tagDelete(String tagId) throws WxErrorException
WxCpTagService.delete(String)WxErrorException@Deprecated List<WxCpTag> tagGet() throws WxErrorException
WxCpTagService.listAll()WxErrorException@Deprecated List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException
WxErrorException@Deprecated void tagAddUsers(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException
WxErrorException@Deprecated void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException
WxErrorException@Deprecated String oauth2buildAuthorizationUrl(String state)
@Deprecated String oauth2buildAuthorizationUrl(String redirectUri, String state)
@Deprecated String[] oauth2getUserInfo(String code) throws WxErrorException
WxErrorException@Deprecated String[] oauth2getUserInfo(Integer agentId, String code) throws WxErrorException
WxErrorExceptionint invite(String userId, String inviteTips) throws WxErrorException
邀请成员关注 http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8
userId - 用户的useridinviteTips - 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。WxErrorExceptionString[] getCallbackIp() throws WxErrorException
获取微信服务器的ip段 http://qydev.weixin.qq.com/wiki/index.php?title=回调模式#.E8.8E.B7.E5.8F.96.E5.BE.AE.E4.BF.A1.E6.9C.8D.E5.8A.A1.E5.99.A8.E7.9A.84ip.E6.AE.B5
WxErrorExceptionString get(String url, String queryParam) throws WxErrorException
url - 接口地址queryParam - 请求参数WxErrorExceptionString post(String url, String postData) throws WxErrorException
url - 接口地址postData - 请求body字符串WxErrorException<T,E> T execute(RequestExecutor<T,E> executor, String uri, E data) throws WxErrorException
Service没有实现某个API的时候,可以用这个, 比get(java.lang.String, java.lang.String)和post(java.lang.String, java.lang.String)方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 可以参考,MediaUploadRequestExecutor的实现方法
T - 请求值类型E - 返回值类型executor - 执行器uri - 请求地址data - 参数WxErrorExceptionvoid setRetrySleepMillis(int retrySleepMillis)
设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试 默认:1000ms
retrySleepMillis - 重试休息时间void setMaxRetryTimes(int maxRetryTimes)
设置当微信系统响应系统繁忙时,最大重试次数 默认:5次
maxRetryTimes - 最大重试次数WxSession getSession(String id)
id - id可以为任意字符串,建议使用FromUserName作为idWxSession getSession(String id, boolean create)
id - id可以为任意字符串,建议使用FromUserName作为idcreate - 是否新建void setSessionManager(WxSessionManager sessionManager)
设置WxSessionManager,只有当需要使用个性化的WxSessionManager的时候才需要调用此方法,
WxCpService默认使用的是StandardSessionManager
sessionManager - 会话管理器String replaceParty(String mediaId) throws WxErrorException
mediaId - 媒体idWxErrorExceptionString replaceUser(String mediaId) throws WxErrorException
mediaId - 媒体idWxErrorExceptionString getTaskResult(String joinId) throws WxErrorException
WxErrorExceptionvoid initHttp()
WxCpConfigStorage getWxCpConfigStorage()
void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider)
WxCpConfigStorage 的实现wxConfigProvider - 配置对象WxCpDepartmentService getDepartmentService()
WxCpMediaService getMediaService()
WxCpMenuService getMenuService()
WxCpOAuth2Service getOauth2Service()
WxCpTagService getTagService()
WxCpUserService getUserService()
RequestHttp getRequestHttp()
void setUserService(WxCpUserService userService)
void setDepartmentService(WxCpDepartmentService departmentService)
void setMediaService(WxCpMediaService mediaService)
void setMenuService(WxCpMenuService menuService)
void setOauth2Service(WxCpOAuth2Service oauth2Service)
void setTagService(WxCpTagService tagService)
Copyright © 2017. All rights reserved.