public class WxMpServiceImpl extends Object implements WxMpService
| 限定符和类型 | 字段和说明 |
|---|---|
protected org.slf4j.Logger |
log |
protected WxSessionManager |
sessionManager |
| 构造器和说明 |
|---|
WxMpServiceImpl() |
| 限定符和类型 | 方法和说明 | ||
|---|---|---|---|
String |
buildQrConnectUrl(String redirectURI,
String scope,
String state)
构造第三方使用网站应用授权登录的url
详情请见:
booleancheckSignature(String timestamp,
String nonce,
String signature)
验证消息的确来自微信服务器
详情请见: http://mp.weixin.qq.com/wiki?
| ||
WxJsapiSignature |
createJsapiSignature(String url)
创建调用jsapi时所需要的签名
详情请见:http://mp.weixin.qq.com/wiki?
|
||
<T,E> T |
execute(RequestExecutor<T,E> executor,
String uri,
E data)
向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求
|
||
protected <T,E> T |
executeInternal(RequestExecutor<T,E> executor,
String uri,
E data) |
||
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?
|
||
WxMpUserBlacklistService |
getBlackListService()
返回用户黑名单管理相关接口方法的实现类对象,以方便调用其各个接口
|
||
String[] |
getCallbackIP()
获取微信服务器IP地址
http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html
|
||
WxMpCardService |
getCardService()
返回卡券相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpDataCubeService |
getDataCubeService()
返回数据分析统计相关接口方法的实现类对象,以方便调用其各个接口
|
||
org.apache.http.impl.client.CloseableHttpClient |
getHttpclient() |
||
org.apache.http.HttpHost |
getHttpProxy()
获取代理对象
|
||
String |
getJsapiTicket()
获得jsapi_ticket,不强制刷新jsapi_ticket
|
||
String |
getJsapiTicket(boolean forceRefresh)
获得jsapi_ticket
获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
详情请见:http://mp.weixin.qq.com/wiki?
|
||
WxMpKefuService |
getKefuService()
返回客服接口方法实现类,以方便调用其各个接口
|
||
WxMpMaterialService |
getMaterialService()
返回素材相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpMenuService |
getMenuService()
返回菜单相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpPayService |
getPayService()
返回微信支付相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpQrcodeService |
getQrcodeService()
返回二维码相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpStoreService |
getStoreService()
返回门店管理相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpTemplateMsgService |
getTemplateMsgService()
返回模板消息相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpUserService |
getUserService()
返回用户相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpUserTagService |
getUserTagService()
返回用户标签相关接口方法的实现类对象,以方便调用其各个接口
|
||
WxMpConfigStorage |
getWxMpConfigStorage()
获取WxMpConfigStorage 对象
|
||
WxMpMassSendResult |
massGroupMessageSend(WxMpMassTagMessage message)
分组群发消息
如果发送图文消息,必须先使用
WxMpService.massNewsUpload(me.chanjar.weixin.mp.bean.WxMpMassNews) 获得media_id,然后再发送
如果发送视频消息,必须先使用 WxMpService.massVideoUpload(me.chanjar.weixin.mp.bean.WxMpMassVideo) 获得media_id,然后再发送
详情请见: http://mp.weixin.qq.com/wiki? |
||
WxMpMassSendResult |
massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage)
群发消息预览接口
开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。
|
||
WxMpMassUploadResult |
massNewsUpload(WxMpMassNews news)
上传群发用的图文消息,上传后才能群发图文消息
详情请见: http://mp.weixin.qq.com/wiki?
|
||
WxMpMassSendResult |
massOpenIdsMessageSend(WxMpMassOpenIdsMessage message)
按openId列表群发消息
如果发送图文消息,必须先使用
WxMpService.massNewsUpload(me.chanjar.weixin.mp.bean.WxMpMassNews) 获得media_id,然后再发送
如果发送视频消息,必须先使用 WxMpService.massVideoUpload(me.chanjar.weixin.mp.bean.WxMpMassVideo) 获得media_id,然后再发送
详情请见: http://mp.weixin.qq.com/wiki? |
||
WxMpMassUploadResult |
massVideoUpload(WxMpMassVideo video)
上传群发用的视频,上传后才能群发视频消息
详情请见: http://mp.weixin.qq.com/wiki?
|
||
String |
oauth2buildAuthorizationUrl(String redirectURI,
String scope,
String state)
构造oauth2授权的url连接
详情请见: http://mp.weixin.qq.com/wiki/index.php?
|
||
WxMpOAuth2AccessToken |
oauth2getAccessToken(String code)
用code换取oauth2的access token
详情请见: http://mp.weixin.qq.com/wiki/index.php?
|
||
WxMpUser |
oauth2getUserInfo(WxMpOAuth2AccessToken oAuth2AccessToken,
String lang)
用oauth2获取用户信息, 当前面引导授权时的scope是snsapi_userinfo的时候才可以
|
||
WxMpOAuth2AccessToken |
oauth2refreshAccessToken(String refreshToken)
刷新oauth2的access token
|
||
boolean |
oauth2validateAccessToken(WxMpOAuth2AccessToken oAuth2AccessToken)
验证oauth2的access token是否有效
|
||
String |
post(String url,
String postData)
当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
|
||
WxMpSemanticQueryResult |
semanticQuery(WxMpSemanticQuery semanticQuery)
语义查询接口
详情请见:http://mp.weixin.qq.com/wiki/index.php?
|
||
void |
setMaxRetryTimes(int maxRetryTimes)
设置当微信系统响应系统繁忙时,最大重试次数
默认:5次
|
||
void |
setRetrySleepMillis(int retrySleepMillis)
设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
默认:1000ms
|
||
void |
setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider)
注入
WxMpConfigStorage 的实现 |
||
String |
shortUrl(String long_url)
长链接转短链接接口
详情请见: http://mp.weixin.qq.com/wiki/index.php?
|
protected final org.slf4j.Logger log
protected 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 在接口中 WxMpServicepublic String getAccessToken() throws WxErrorException
WxMpServicegetAccessToken 在接口中 WxMpServiceWxErrorExceptionWxMpService.getAccessToken(boolean)public String getAccessToken(boolean forceRefresh) throws WxErrorException
WxMpService获取access_token,本方法线程安全 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限 另:本service的所有方法都会在access_token过期是调用此方法 程序员在非必要情况下尽量不要主动调用此方法 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN
getAccessToken 在接口中 WxMpServiceforceRefresh - 强制刷新WxErrorExceptionpublic String getJsapiTicket() throws WxErrorException
WxMpServicegetJsapiTicket 在接口中 WxMpServiceWxErrorExceptionWxMpService.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 - 强制刷新WxErrorExceptionpublic 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 在接口中 WxMpServiceWxErrorExceptionpublic WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException
WxMpService上传群发用的图文消息,上传后才能群发图文消息 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException
WxMpService上传群发用的视频,上传后才能群发视频消息 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException
WxMpService分组群发消息 如果发送图文消息,必须先使用WxMpService.massNewsUpload(me.chanjar.weixin.mp.bean.WxMpMassNews)获得media_id,然后再发送 如果发送视频消息,必须先使用WxMpService.massVideoUpload(me.chanjar.weixin.mp.bean.WxMpMassVideo)获得media_id,然后再发送 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
massGroupMessageSend 在接口中 WxMpServiceWxErrorExceptionpublic WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException
WxMpService按openId列表群发消息 如果发送图文消息,必须先使用WxMpService.massNewsUpload(me.chanjar.weixin.mp.bean.WxMpMassNews)获得media_id,然后再发送 如果发送视频消息,必须先使用WxMpService.massVideoUpload(me.chanjar.weixin.mp.bean.WxMpMassVideo)获得media_id,然后再发送 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
massOpenIdsMessageSend 在接口中 WxMpServiceWxErrorExceptionpublic WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception
WxMpService群发消息预览接口 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。为了满足第三方平台开发者的需求,在保留对openID预览能力的同时,增加了对指定微信号发送预览的能力,但该能力每日调用次数有限制(100次),请勿滥用。 接口调用请求说明 http请求方式: POST https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
massMessagePreview 在接口中 WxMpServiceExceptionpublic String shortUrl(String long_url) throws WxErrorException
WxMpService长链接转短链接接口 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=长链接转短链接接口
shortUrl 在接口中 WxMpServiceWxErrorExceptionpublic WxMpSemanticQueryResult semanticQuery(WxMpSemanticQuery semanticQuery) throws WxErrorException
WxMpService语义查询接口 详情请见:http://mp.weixin.qq.com/wiki/index.php?title=语义理解
semanticQuery 在接口中 WxMpServiceWxErrorExceptionpublic String oauth2buildAuthorizationUrl(String redirectURI, String scope, String state)
WxMpService构造oauth2授权的url连接 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
oauth2buildAuthorizationUrl 在接口中 WxMpServiceredirectURI - 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encodepublic 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 WxMpOAuth2AccessToken oauth2getAccessToken(String code) throws WxErrorException
WxMpService用code换取oauth2的access token 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
oauth2getAccessToken 在接口中 WxMpServiceWxErrorExceptionpublic WxMpOAuth2AccessToken oauth2refreshAccessToken(String refreshToken) throws WxErrorException
WxMpService刷新oauth2的access token
oauth2refreshAccessToken 在接口中 WxMpServiceWxErrorExceptionpublic WxMpUser oauth2getUserInfo(WxMpOAuth2AccessToken oAuth2AccessToken, String lang) throws WxErrorException
WxMpService用oauth2获取用户信息, 当前面引导授权时的scope是snsapi_userinfo的时候才可以
oauth2getUserInfo 在接口中 WxMpServicelang - zh_CN, zh_TW, enWxErrorExceptionpublic boolean oauth2validateAccessToken(WxMpOAuth2AccessToken oAuth2AccessToken)
WxMpService验证oauth2的access token是否有效
oauth2validateAccessToken 在接口中 WxMpServicepublic String[] getCallbackIP() throws WxErrorException
WxMpService获取微信服务器IP地址 http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html
getCallbackIP 在接口中 WxMpServiceWxErrorExceptionpublic String get(String url, String queryParam) throws WxErrorException
WxMpServiceget 在接口中 WxMpServiceWxErrorExceptionpublic String post(String url, String postData) throws WxErrorException
WxMpServicepost 在接口中 WxMpServiceWxErrorExceptionpublic <T,E> T execute(RequestExecutor<T,E> executor, String uri, E data) throws WxErrorException
execute 在接口中 WxMpServiceWxErrorExceptionprotected <T,E> T executeInternal(RequestExecutor<T,E> executor, String uri, E data) throws WxErrorException
WxErrorExceptionpublic org.apache.http.HttpHost getHttpProxy()
WxMpServicegetHttpProxy 在接口中 WxMpServicepublic org.apache.http.impl.client.CloseableHttpClient getHttpclient()
public void setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider)
WxMpServiceWxMpConfigStorage 的实现setWxMpConfigStorage 在接口中 WxMpServicepublic WxMpConfigStorage getWxMpConfigStorage()
WxMpServicegetWxMpConfigStorage 在接口中 WxMpServicepublic void setRetrySleepMillis(int retrySleepMillis)
WxMpService设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试 默认:1000ms
setRetrySleepMillis 在接口中 WxMpServicepublic void setMaxRetryTimes(int maxRetryTimes)
WxMpService设置当微信系统响应系统繁忙时,最大重试次数 默认:5次
setMaxRetryTimes 在接口中 WxMpServicepublic WxMpKefuService getKefuService()
WxMpServicegetKefuService 在接口中 WxMpServicepublic WxMpMaterialService getMaterialService()
WxMpServicegetMaterialService 在接口中 WxMpServicepublic WxMpMenuService getMenuService()
WxMpServicegetMenuService 在接口中 WxMpServicepublic WxMpUserService getUserService()
WxMpServicegetUserService 在接口中 WxMpServicepublic WxMpUserTagService getUserTagService()
WxMpServicegetUserTagService 在接口中 WxMpServicepublic WxMpQrcodeService getQrcodeService()
WxMpServicegetQrcodeService 在接口中 WxMpServicepublic WxMpCardService getCardService()
WxMpServicegetCardService 在接口中 WxMpServicepublic WxMpPayService getPayService()
WxMpServicegetPayService 在接口中 WxMpServicepublic WxMpDataCubeService getDataCubeService()
WxMpServicegetDataCubeService 在接口中 WxMpServicepublic WxMpUserBlacklistService getBlackListService()
WxMpServicegetBlackListService 在接口中 WxMpServicepublic WxMpStoreService getStoreService()
WxMpServicegetStoreService 在接口中 WxMpServicepublic WxMpTemplateMsgService getTemplateMsgService()
WxMpServicegetTemplateMsgService 在接口中 WxMpServiceCopyright © 2016. All rights reserved.