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?
|
<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请求对象
|
WxCpMessageSendResult |
messageSend(WxCpMessage message)
发送消息
详情请见: http://qydev.weixin.qq.com/wiki/index.php?
|
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 的实现 |
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
WxErrorException
getAccessToken(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
- 强制刷新WxErrorException
String getJsapiTicket() throws WxErrorException
WxErrorException
getJsapiTicket(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
- 强制刷新WxErrorException
WxJsapiSignature 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
WxCpMessageSendResult 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
String[] 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
WxErrorException
String get(String url, String queryParam) throws WxErrorException
url
- 接口地址queryParam
- 请求参数WxErrorException
String 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
- 参数WxErrorException
void 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
- 媒体idWxErrorException
String replaceUser(String mediaId) throws WxErrorException
mediaId
- 媒体idWxErrorException
String getTaskResult(String joinId) throws WxErrorException
WxErrorException
void 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 © 2018. All rights reserved.