com.jfinal.weixin.sdk.kit.ParaMap Java Examples
The following examples show how to use
com.jfinal.weixin.sdk.kit.ParaMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccessTokenApi.java From jfinal-weixin with Apache License 2.0 | 6 votes |
/** * 强制更新 access token 值 */ public static synchronized void refreshAccessToken() { ApiConfig ac = ApiConfigKit.getApiConfig(); AccessToken result = null; for (int i=0; i<3; i++) { // 最多三次请求 String appId = ac.getAppId(); String appSecret = ac.getAppSecret(); Map<String, String> queryParas = ParaMap.create("appid", appId).put("secret", appSecret).getData(); String json = HttpKit.get(url, queryParas); result = new AccessToken(json); if (result.isAvailable()) break; } // 三次请求如果仍然返回了不可用的 access token 仍然 put 进去,便于上层通过 AccessToken 中的属性判断底层的情况 accessTokenCache.set(ac.getAppId(), result); }
Example #2
Source File: WechatApis.java From jboot with Apache License 2.0 | 5 votes |
/** * http GET请求获得jsapi_ticket(有效期7200秒,开发者必须在自己的服务全局缓存jsapi_ticket) * * @param jsApiType jsApi类型 * @return JsTicket */ public static JsTicket getTicket(JsApiType jsApiType) { String access_token = AccessTokenApi.getAccessTokenStr(); String appId = ApiConfigKit.getApiConfig().getAppId(); String key = appId + ':' + jsApiType.name(); final ParaMap pm = ParaMap.create("access_token", access_token).put("type", jsApiType.name()); // 2016.07.21修改By L.cm 为了更加方便扩展 String jsTicketJson = ApiConfigKit.getAccessTokenCache().get(key); JsTicket jsTicket = null; if (StrKit.notBlank(jsTicketJson)) { jsTicket = new JsTicket(jsTicketJson); } if (null == jsTicket || !jsTicket.isAvailable()) { // 最多三次请求 jsTicket = RetryUtils.retryOnException(3, new Callable<JsTicket>() { @Override public JsTicket call() throws Exception { return new JsTicket(HttpUtils.get(apiUrl, pm.getData())); } }); if (null != jsApiType) { ApiConfigKit.getAccessTokenCache().set(key, jsTicket.getCacheJson()); } } return jsTicket; }
Example #3
Source File: JsTicketApi.java From jfinal-weixin with Apache License 2.0 | 5 votes |
/** * * http GET请求获得jsapi_ticket(有效期7200秒,开发者必须在自己的服务全局缓存jsapi_ticket) * * @param jsApiType * @return JsTicket */ public static JsTicket getTicket(JsApiType jsApiType) { String access_token = AccessTokenApi.getAccessTokenStr(); String appId = ApiConfigKit.getApiConfig().getAppId(); String key = appId + ':' + jsApiType.name(); JsTicket jsTicket = accessTokenCache.get(key); if (null == jsTicket || !jsTicket.isAvailable()) { ParaMap pm = ParaMap.create("access_token", access_token).put("type", jsApiType.name()); jsTicket = new JsTicket(HttpKit.get(apiUrl, pm.getData())); accessTokenCache.set(key, jsTicket); } return jsTicket; }
Example #4
Source File: UserApi.java From jfinal-weixin with Apache License 2.0 | 5 votes |
/** * 获取用户列表 * @param nextOpenid 第一个拉取的OPENID,不填默认从头开始拉取 * @return ApiResult */ public static ApiResult getFollowers(String nextOpenid) { ParaMap pm = ParaMap.create("access_token", AccessTokenApi.getAccessTokenStr()); if (nextOpenid != null) pm.put("next_openid", nextOpenid); return new ApiResult(HttpKit.get(getFollowers, pm.getData())); }
Example #5
Source File: SnsAccessTokenApi.java From jfinal-weixin with Apache License 2.0 | 5 votes |
/** * 通过code获取access_token * * @param code 第一步获取的code参数 * @param appId 应用唯一标识 * @param secret 应用密钥AppSecret * @return SnsAccessToken */ public static SnsAccessToken getSnsAccessToken(String appId, String secret, String code) { SnsAccessToken result = null; for (int i = 0; i < 3; i++) { // 最多三次请求 Map<String, String> queryParas = ParaMap.create("appid", appId).put("secret", secret).put("code", code).getData(); String json = HttpKit.get(url, queryParas); result = new SnsAccessToken(json); if (result.isAvailable()) break; } return result; }
Example #6
Source File: WechatAuthorizationController.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
private static ApiResult getUserInfo(String openId, String accessToken) { ParaMap pm = ParaMap.create("access_token", accessToken).put("openid", openId).put("lang", "zh_CN"); return new ApiResult(HttpKit.get("https://api.weixin.qq.com/sns/userinfo", pm.getData())); }
Example #7
Source File: SnsApi.java From jfinal-weixin with Apache License 2.0 | 2 votes |
/** * 获取用户个人信 * @param accessToken 调用凭证access_token * @param openId 普通用户的标识,对当前开发者帐号唯一 * @return ApiResult */ public static ApiResult getUserInfo(String accessToken, String openId) { ParaMap pm = ParaMap.create("access_token", accessToken).put("openid", openId).put("lang", "zh_CN"); return new ApiResult(HttpKit.get(getUserInfo, pm.getData())); }
Example #8
Source File: UserApi.java From jfinal-weixin with Apache License 2.0 | 2 votes |
/** * 获取用户基本信息(包括UnionID机制) * @param openId 普通用户的标识,对当前公众号唯一 * @return ApiResult */ public static ApiResult getUserInfo(String openId) { ParaMap pm = ParaMap.create("access_token", AccessTokenApi.getAccessTokenStr()).put("openid", openId).put("lang", "zh_CN"); return new ApiResult(HttpKit.get(getUserInfo, pm.getData())); }