Java Code Examples for com.jfinal.kit.HttpKit#get()
The following examples show how to use
com.jfinal.kit.HttpKit#get() .
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: 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 3
Source File: MediaApi.java From jfinal-weixin with Apache License 2.0 | 5 votes |
/** * 获取素材总数 * @return ApiResult 返回信息 */ public static ApiResult getMaterialCount() { String url = get_materialcount_url + AccessTokenApi.getAccessTokenStr(); System.out.println(url); String jsonResult = HttpKit.get(url); return new ApiResult(jsonResult); }
Example 4
Source File: GroupsApi.java From jfinal-weixin with Apache License 2.0 | 5 votes |
/** * 查询所有分组 * @return ApiResult */ public static ApiResult get() { String url = getUrl + AccessTokenApi.getAccessTokenStr(); String jsonResult = HttpKit.get(url); return new ApiResult(jsonResult); }
Example 5
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 6
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 7
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 8
Source File: CallbackIpApi.java From jfinal-weixin with Apache License 2.0 | 4 votes |
/** * 获取微信服务器IP地址 */ public static ApiResult getCallbackIp() { String jsonResult = HttpKit.get(apiUrl + AccessTokenApi.getAccessTokenStr()); return new ApiResult(jsonResult); }
Example 9
Source File: MenuApi.java From jfinal-weixin with Apache License 2.0 | 4 votes |
/** * 查询菜单 */ public static ApiResult getMenu() { String jsonResult = HttpKit.get(getMenu + AccessTokenApi.getAccessTokenStr()); return new ApiResult(jsonResult); }
Example 10
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 11
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())); }