public class WechatMpCore extends Object implements WechatMpApi
cgi_bin_ticket_getticket, cgibin_add_template, cgibin_get_industry, cgibin_send_data, cgibin_set_industry, cgibin_token, oauth2_access_token, oauth2_refresh_token, sns_auth_token, sns_userinfo| 构造器和说明 |
|---|
WechatMpCore() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
generateWechatUrl(String appId,
String scope,
String callback,
String bizData)
wechat URL链接生成,
scope取值为:snsapi_base[无需用户授权] 或 userinfo[需用户授权]
state 为自定义参数,非必须
redirect_uri 微信处理完成后,会直接转向至该地址
|
static MpGetIndustryResponse |
getIndustry(String accessToken)
获取行业属性.
|
static boolean |
isFromWechat(javax.servlet.http.HttpServletRequest request)
验证请求是否来自微信
|
static boolean |
isvalidOauthAccessToken(Map<String,Object> mapToken)
检验授权凭证(access_token)是否有效
|
static MpTokenResponse |
obtainAccessToken(String appid,
String secret)
access_token是公众号的全局唯一接口调用凭据,公众号调用各接口时都需使用access_token。
|
static MpJsApiTicketResponse |
obtainJsApiTicket(String token)
获取jsapi_ticket,jsapi_ticket是公众号用于调用微信JS接口的临时票据。
|
static MpJsApiTicketResponse |
obtainJsApiTicket(String appid,
String secret)
功能同上,但不建议使用,token需要中控服务器维护
|
static MpOauthTokenResponse |
obtainOauthAccessToken(Map<String,Object> mapToken)
通过code换取网页授权access_token
access_token是调用授权关系接口的调用凭证,有效期为2个小时,频率限制:1万/分钟
|
static MpTemplateResponse |
obtainTemplateId(String accessToken,
String templateIdShort)
获取微信消息模板ID{根据微信template_id_short得到,实际动作是调用API往 ‘我的模板’ 中添加了模板}
|
static MpUserInfoResponse |
obtainUserInfo(Map<String,Object> userInfoMap)
获取微信用户个人信息
所需参数:access_token、openid、lang[非必须]
lang 国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语,默认为zh-CN
频率限制:5万/分钟
|
static MpOauthTokenResponse |
refreshOauthAccessToken(Map<String,Object> mapToken)
刷新access_token(如果需要)
当access_token超时后,可以使用refresh_token进行刷新,access_token刷新结果有两种
1.
|
static MpSendDataResponse |
sendMsgToUser(String accessToken,
String data)
发送数据至于用户公微信所关注的微信公账号
|
static MpSetIndustryResponse |
setupIndustry(String accessToken,
String industryId1,
String industryId2)
设置行业属性
|
public static MpOauthTokenResponse obtainOauthAccessToken(Map<String,Object> mapToken) throws Exception
mapToken - the map tokenException - the exceptionpublic static MpOauthTokenResponse refreshOauthAccessToken(Map<String,Object> mapToken) throws Exception
mapToken - the map tokenException - the exceptionpublic static String generateWechatUrl(String appId, String scope, String callback, String bizData)
appId - the app idscope - the scopecallback - the callbackbizData - the biz datapublic static MpUserInfoResponse obtainUserInfo(Map<String,Object> userInfoMap) throws Exception
userInfoMap - the user info mapException - the exceptionpublic static boolean isvalidOauthAccessToken(Map<String,Object> mapToken) throws Exception
mapToken - the map tokenException - the exceptionpublic static MpTokenResponse obtainAccessToken(String appid, String secret) throws Exception
appid - the appidsecret - the secretException - the exceptionpublic static MpJsApiTicketResponse obtainJsApiTicket(String token) throws Exception
token - 普通tokenException - the exceptionpublic static MpJsApiTicketResponse obtainJsApiTicket(String appid, String secret) throws Exception
appid - the appidsecret - the secretException - the exceptionpublic static MpTemplateResponse obtainTemplateId(String accessToken, String templateIdShort) throws Exception
accessToken - the access tokentemplateIdShort - the template id shortException - the exceptionpublic static MpSetIndustryResponse setupIndustry(String accessToken, String industryId1, String industryId2) throws Exception
accessToken - the access tokenindustryId1 - the industry id 1industryId2 - the industry id 2Exception - the exceptionpublic static MpGetIndustryResponse getIndustry(String accessToken) throws Exception
accessToken - the access tokenException - the exceptionpublic static MpSendDataResponse sendMsgToUser(String accessToken, String data) throws Exception
accessToken - the access tokendata - json格式数据,这里是JSON数据,是的MpSendDataRequest JSON格式Exception - the exceptionpublic static boolean isFromWechat(javax.servlet.http.HttpServletRequest request)
request - the requestCopyright © 2019. All rights reserved.