public abstract class BaseWxMpServiceImpl<H,P> extends Object implements WxMpService, RequestHttp<H,P>
| 限定符和类型 | 字段和说明 |
|---|---|
protected WxSessionManager |
sessionManager |
| 构造器和说明 |
|---|
BaseWxMpServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addConfigStorage(String mpId,
WxMpConfigStorage configStorages)
Map里 加入新的
WxMpConfigStorage,适用于动态添加新的微信公众号配置. |
String |
buildQrConnectUrl(String redirectUri,
String scope,
String state)
构造第三方使用网站应用授权登录的url.
|
boolean |
checkSignature(String timestamp,
String nonce,
String signature)
验证消息的确来自微信服务器.
|
void |
clearQuota(String appid)
公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零:
HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?
|
WxJsapiSignature |
createJsapiSignature(String url)
创建调用jsapi时所需要的签名.
|
<T,E> T |
execute(RequestExecutor<T,E> executor,
String uri,
E data)
向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求.
|
<T,E> T |
execute(RequestExecutor<T,E> executor,
WxMpApiUrl url,
E data)
Service没有实现某个API的时候,可以用这个,
比
WxMpService.get(me.chanjar.weixin.mp.enums.WxMpApiUrl, java.lang.String)和WxMpService.post(me.chanjar.weixin.mp.enums.WxMpApiUrl, java.lang.String)方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 |
protected <T,E> T |
executeInternal(RequestExecutor<T,E> executor,
String uri,
E data) |
protected String |
extractAccessToken(String resultContent) |
String |
get(String url,
String queryParam) |
String |
get(WxMpApiUrl url,
String queryParam)
当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
|
String |
getAccessToken()
获取access_token, 不强制刷新access_token.
|
String[] |
getCallbackIP()
获取微信服务器IP地址
http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html
|
WxMpCurrentAutoReplyInfo |
getCurrentAutoReplyInfo()
获取公众号的自动回复规则.
|
String |
getJsapiTicket()
获得jsapi_ticket,不强制刷新jsapi_ticket.
|
String |
getJsapiTicket(boolean forceRefresh)
获得jsapi_ticket.
|
RequestHttp |
getRequestHttp()
获取RequestHttp对象.
|
String |
getTicket(TicketType type)
获得ticket,不强制刷新ticket.
|
String |
getTicket(TicketType type,
boolean forceRefresh)
获得ticket.
|
WxMpConfigStorage |
getWxMpConfigStorage()
获取WxMpConfigStorage 对象.
|
WxNetCheckResult |
netCheck(String action,
String operator)
网络检测
https://mp.weixin.qq.com/wiki?
|
String |
post(String url,
Object obj) |
String |
post(String url,
String postData) |
String |
post(WxMpApiUrl url,
String postData)
当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
|
void |
removeConfigStorage(String mpId)
从 Map中 移除
mpId 所对应的 WxMpConfigStorage,适用于动态移除微信公众号配置. |
WxMpSemanticQueryResult |
semanticQuery(WxMpSemanticQuery semanticQuery)
语义查询接口.
|
void |
setMaxRetryTimes(int maxRetryTimes)
设置当微信系统响应系统繁忙时,最大重试次数.
|
void |
setMultiConfigStorages(Map<String,WxMpConfigStorage> configStorages)
注入多个
WxMpConfigStorage 的实现. |
void |
setMultiConfigStorages(Map<String,WxMpConfigStorage> configStorages,
String defaultMpId)
注入多个
WxMpConfigStorage 的实现. |
void |
setRetrySleepMillis(int retrySleepMillis)
设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试.
|
void |
setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider)
设置
WxMpConfigStorage 的实现. |
String |
shortUrl(String longUrl)
长链接转短链接接口.
|
boolean |
switchover(String mpId)
进行相应的公众号切换.
|
WxMpService |
switchoverTo(String mpId)
进行相应的公众号切换.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAccessToken, getAiOpenService, getBlackListService, getCardService, getCommentService, getDataCubeService, getDeviceService, getImgProcService, getKefuService, getMarketingService, getMassMessageService, getMaterialService, getMemberCardService, getMenuService, getOAuth2Service, getOcrService, getQrcodeService, getShakeService, getStoreService, getSubscribeMsgService, getTemplateMsgService, getUserService, getUserTagService, getWifiService, initHttp, setAiOpenService, setBlackListService, setCardService, setCommentService, setDataCubeService, setDeviceService, setImgProcService, setKefuService, setMarketingService, setMassMessageService, setMaterialService, setMemberCardService, setMenuService, setOAuth2Service, setOcrService, setQrcodeService, setShakeService, setStoreService, setTemplateMsgService, setUserService, setUserTagServicegetRequestHttpClient, getRequestHttpProxy, getRequestTypeprotected WxSessionManager sessionManager
public boolean checkSignature(String timestamp, String nonce, String signature)
WxMpService验证消息的确来自微信服务器. 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN
checkSignature 在接口中 WxMpServicetimestamp - 时间戳nonce - 随机串signature - 签名public String getTicket(TicketType type) throws WxErrorException
WxMpServicegetTicket 在接口中 WxMpServicetype - ticket 类型WxErrorException - .WxMpService.getTicket(TicketType, boolean)public String getTicket(TicketType type, boolean forceRefresh) throws WxErrorException
WxMpService获得ticket. 获得时会检查 Token是否过期,如果过期了,那么就刷新一下,否则就什么都不干
getTicket 在接口中 WxMpServicetype - ticket类型forceRefresh - 强制刷新WxErrorException - .public String getJsapiTicket() throws WxErrorException
WxMpServicegetJsapiTicket 在接口中 WxMpServiceWxErrorException - .WxMpService.getJsapiTicket(boolean)public String getJsapiTicket(boolean forceRefresh) throws WxErrorException
WxMpService获得jsapi_ticket. 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
getJsapiTicket 在接口中 WxMpServiceforceRefresh - 强制刷新WxErrorException - .public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
WxMpService创建调用jsapi时所需要的签名. 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
createJsapiSignature 在接口中 WxMpServiceurl - 地址WxErrorException - .public String getAccessToken() throws WxErrorException
WxMpServicegetAccessToken 在接口中 WxMpServiceWxErrorException - .WxMpService.getAccessToken(boolean)public String shortUrl(String longUrl) throws WxErrorException
WxMpService长链接转短链接接口. 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=长链接转短链接接口
shortUrl 在接口中 WxMpServicelongUrl - 长urlWxErrorException - .public WxMpSemanticQueryResult semanticQuery(WxMpSemanticQuery semanticQuery) throws WxErrorException
WxMpService语义查询接口. 详情请见:http://mp.weixin.qq.com/wiki/index.php?title=语义理解
semanticQuery 在接口中 WxMpServicesemanticQuery - 查询条件WxErrorException - .public String buildQrConnectUrl(String redirectUri, String scope, String state)
WxMpService构造第三方使用网站应用授权登录的url. 详情请见: 网站应用微信登录开发指南 URL格式为:https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
buildQrConnectUrl 在接口中 WxMpServiceredirectUri - 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encodescope - 应用授权作用域,拥有多个作用域用逗号(,)分隔,网页应用目前仅填写snsapi_login即可state - 非必填,用于保持请求和回调的状态,授权请求后原样带回给第三方。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议第三方带上该参数,可设置为简单的随机数加session进行校验public String[] getCallbackIP() throws WxErrorException
WxMpService获取微信服务器IP地址 http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html
getCallbackIP 在接口中 WxMpServiceWxErrorException - .public WxNetCheckResult netCheck(String action, String operator) throws WxErrorException
WxMpService网络检测 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21541575776DtsuT 为了帮助开发者排查回调连接失败的问题,提供这个网络检测的API。它可以对开发者URL做域名解析,然后对所有IP进行一次ping操作,得到丢包率和耗时。
netCheck 在接口中 WxMpServiceaction - 执行的检测动作operator - 指定平台从某个运营商进行检测WxErrorException - .public WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException
WxMpService获取公众号的自动回复规则. https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Getting_Rules_for_Auto_Replies.html 开发者可以通过该接口,获取公众号当前使用的自动回复规则,包括关注后自动回复、消息自动回复(60分钟内触发一次)、关键词自动回复。 请注意: 1、第三方平台开发者可以通过本接口,在旗下公众号将业务授权给你后,立即通过本接口检测公众号的自动回复配置,并通过接口再次给公众号设置好自动回复规则,以提升公众号运营者的业务体验。 2、本接口仅能获取公众号在公众平台官网的自动回复功能中设置的自动回复规则,若公众号自行开发实现自动回复,或通过第三方平台开发者来实现,则无法获取。 3、认证/未认证的服务号/订阅号,以及接口测试号,均拥有该接口权限。 4、从第三方平台的公众号登录授权机制上来说,该接口从属于消息与菜单权限集。 5、本接口中返回的图片/语音/视频为临时素材(临时素材每次获取都不同,3天内有效,通过素材管理-获取临时素材接口来获取这些素材),本接口返回的图文消息为永久素材素材(通过素材管理-获取永久素材接口来获取这些素材)。 接口调用请求说明 http请求方式: GET(请使用https协议) https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=ACCESS_TOKEN
getCurrentAutoReplyInfo 在接口中 WxMpServiceWxErrorException - .public void clearQuota(String appid) throws WxErrorException
WxMpService公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零: HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN 接口文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592
clearQuota 在接口中 WxMpServiceappid - 公众号的APPIDWxErrorException - the wx error exceptionpublic String get(String url, String queryParam) throws WxErrorException
get 在接口中 WxServiceWxErrorExceptionpublic String get(WxMpApiUrl url, String queryParam) throws WxErrorException
WxMpServiceget 在接口中 WxMpServiceurl - 请求接口地址queryParam - 参数WxErrorException - 异常public String post(String url, String postData) throws WxErrorException
post 在接口中 WxServiceWxErrorExceptionpublic String post(WxMpApiUrl url, String postData) throws WxErrorException
WxMpServicepost 在接口中 WxMpServiceurl - 请求接口地址postData - 请求参数json值WxErrorException - 异常public String post(String url, Object obj) throws WxErrorException
post 在接口中 WxServiceWxErrorExceptionpublic <T,E> T execute(RequestExecutor<T,E> executor, WxMpApiUrl url, E data) throws WxErrorException
WxMpServiceService没有实现某个API的时候,可以用这个, 比WxMpService.get(me.chanjar.weixin.mp.enums.WxMpApiUrl, java.lang.String)和WxMpService.post(me.chanjar.weixin.mp.enums.WxMpApiUrl, java.lang.String)方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 可以参考,MediaUploadRequestExecutor的实现方法
execute 在接口中 WxMpServiceT - the type parameterE - the type parameterexecutor - 执行器url - 接口地址data - 参数数据WxErrorException - 异常public <T,E> T execute(RequestExecutor<T,E> executor, String uri, E data) throws WxErrorException
execute 在接口中 WxMpServiceT - the type parameterE - the type parameterexecutor - 执行器uri - 接口地址data - 参数数据WxErrorException - 异常protected <T,E> T executeInternal(RequestExecutor<T,E> executor, String uri, E data) throws WxErrorException
WxErrorExceptionpublic WxMpConfigStorage getWxMpConfigStorage()
WxMpServicegetWxMpConfigStorage 在接口中 WxMpServiceprotected String extractAccessToken(String resultContent) throws WxErrorException
WxErrorExceptionpublic void setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider)
WxMpServiceWxMpConfigStorage 的实现. 兼容老版本setWxMpConfigStorage 在接口中 WxMpServicewxConfigProvider - .public void setMultiConfigStorages(Map<String,WxMpConfigStorage> configStorages)
WxMpServicesetMultiConfigStorages 在接口中 WxMpServiceconfigStorages - WxMpConfigStorage mappublic void setMultiConfigStorages(Map<String,WxMpConfigStorage> configStorages, String defaultMpId)
WxMpServicesetMultiConfigStorages 在接口中 WxMpServiceconfigStorages - WxMpConfigStorage mapdefaultMpId - 设置一个WxMpConfigStorage 所对应的mpId进行Http初始化public void addConfigStorage(String mpId, WxMpConfigStorage configStorages)
WxMpServiceWxMpConfigStorage,适用于动态添加新的微信公众号配置.addConfigStorage 在接口中 WxMpServicempId - 公众号idconfigStorages - 新的微信配置public void removeConfigStorage(String mpId)
WxMpServicempId 所对应的 WxMpConfigStorage,适用于动态移除微信公众号配置.removeConfigStorage 在接口中 WxMpServicempId - 对应公众号的标识public WxMpService switchoverTo(String mpId)
WxMpServiceswitchoverTo 在接口中 WxMpServicempId - 公众号标识public boolean switchover(String mpId)
WxMpServiceswitchover 在接口中 WxMpServicempId - 公众号标识public void setRetrySleepMillis(int retrySleepMillis)
WxMpServicesetRetrySleepMillis 在接口中 WxMpServiceretrySleepMillis - 默认:1000mspublic void setMaxRetryTimes(int maxRetryTimes)
WxMpService设置当微信系统响应系统繁忙时,最大重试次数. 默认:5次
setMaxRetryTimes 在接口中 WxMpServicemaxRetryTimes - 最大重试次数public RequestHttp getRequestHttp()
WxMpServicegetRequestHttp 在接口中 WxMpServiceCopyright © 2020. All rights reserved.