Java Code Examples for com.jfinal.kit.HttpKit#post()

The following examples show how to use com.jfinal.kit.HttpKit#post() . 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: MediaApi.java    From jfinal-weixin with Apache License 2.0 6 votes vote down vote up
/**
 * 获取素材列表
 * @param mediaType 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
 * @param offset 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回
 * @param count 返回素材的数量,取值在1到20之间
 * @return ApiResult 返回信息
 */
public static ApiResult batchGetMaterial(MediaType mediaType, int offset, int count) {
	String url = batchget_material_url + AccessTokenApi.getAccessTokenStr();
	
	if(offset < 0) offset = 0;
	if(count > 20) count = 20;
	if(count < 1) count = 1;
	
	Map<String, Object> dataMap = new HashMap<String, Object>();
	dataMap.put("type", mediaType.get());
	dataMap.put("offset", offset);
	dataMap.put("count", count);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(dataMap));
	return new ApiResult(jsonResult);
}
 
Example 2
Source File: MediaApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 视频群发的消息素材上传
 * @param mediaId 用于群发的消息的media_id
 * @param title 消息的标题
 * @param description 消息的描述
 * @return
 */
public static ApiResult uploadVideo(String mediaId, String title, String description) {
	String url = uploadVideoUrl + AccessTokenApi.getAccessTokenStr();
	
	Map<String, String> mapData = new HashMap<String, String>();
	mapData.put("media_id", mediaId);
	mapData.put("title", title);
	mapData.put("description", description);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(mapData));
	return new ApiResult(jsonResult);
}
 
Example 3
Source File: PaymentApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 支付相关请求
 */
private static Map<String, String> request(String url, Map<String, String> params, String paternerKey) {
	params.put("nonce_str", PaymentKit.getUUID());
	String sign = PaymentKit.createSign(params, paternerKey);
	params.put("sign", sign);
	String xmlStr = HttpKit.post(url, PaymentKit.toXml(params));
	return PaymentKit.xmlToMap(xmlStr);
}
 
Example 4
Source File: MediaApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 删除永久素材
 * @param media_id 要获取的素材的media_id
 * @return ApiResult 返回信息
 */
public static ApiResult delMaterial(String media_id) {
	String url = del_material_url + AccessTokenApi.getAccessTokenStr();
	
	Map<String, Object> dataMap = new HashMap<String, Object>();
	dataMap.put("media_id", media_id);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(dataMap));
	return new ApiResult(jsonResult);
}
 
Example 5
Source File: UserApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 设置备注名
 * @param openid 用户标识
 * @param remark 新的备注名,长度必须小于30字符
 * @return
 */
public static ApiResult updateRemark(String openid, String remark) {
	String url = updateRemarkUrl + AccessTokenApi.getAccessTokenStr();
	
	Map<String, String> mapData = new HashMap<String, String>();
	mapData.put("openid", openid);
	mapData.put("remark", remark);
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(mapData));
	
	return new ApiResult(jsonResult);
}
 
Example 6
Source File: GroupsApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 删除分组
 * @param id 分组的id
 * @return ApiResult
 */
public static ApiResult delete(int id) {
	String url = deleteUrl + AccessTokenApi.getAccessTokenStr();
	
	Map<String, Map<String, Object>> groupData = new HashMap<String, Map<String, Object>>();
	Map<String, Object> mapData = new HashMap<String, Object>();
	mapData.put("id", id);
	groupData.put("group", mapData);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(groupData));
	return new ApiResult(jsonResult);
}
 
Example 7
Source File: GroupsApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 批量移动用户分组
 * @param openidList 用户唯一标识符openid的列表(size不能超过50)
 * @param to_groupid 分组id
 * @return ApiResult
 */
public static ApiResult membersBatchUpdate(List<String> openidList, int to_groupid) {
	String url = membersBatchUpdateUrl + AccessTokenApi.getAccessTokenStr();
	
	Map<String, Object> mapData = new HashMap<String, Object>();
	mapData.put("openid_list", openidList);
	mapData.put("to_groupid", to_groupid);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(mapData));
	return new ApiResult(jsonResult);
}
 
Example 8
Source File: GroupsApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 创建分组,一个公众账号,最多支持创建100个分组。
 * @param name 分组名
 * @return ApiResult
 */
public static ApiResult create(String name) {
	String url = createUrl + AccessTokenApi.getAccessTokenStr();
	
	Map<String, Map<String, String>> groupData = new HashMap<String, Map<String, String>>();
	Map<String, String> mapData = new HashMap<String, String>();
	mapData.put("name", name);
	groupData.put("group", mapData);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(groupData));
	return new ApiResult(jsonResult);
}
 
Example 9
Source File: GroupsApi.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 修改分组名
 * @param id 分组id,由微信分配
 * @param name 分组名字(30个字符以内)
 * @return ApiResult
 */
public static ApiResult update(int id, String name) {
	String url = updateUrl + AccessTokenApi.getAccessTokenStr();
	
	Map<String, Map<String, Object>> groupData = new HashMap<String, Map<String, Object>>();
	Map<String, Object> mapData = new HashMap<String, Object>();
	mapData.put("id", id);
	mapData.put("name", name);
	groupData.put("group", mapData);
	
	String jsonResult = HttpKit.post(url, JsonUtils.toJson(groupData));
	return new ApiResult(jsonResult);
}
 
Example 10
Source File: TemplateMsgApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
/**
 * 发送模板消息
 */
public static ApiResult send(String jsonStr) {
	String jsonResult = HttpKit.post(sendApiUrl + AccessTokenApi.getAccessToken().getAccessToken(), jsonStr);
	return new ApiResult(jsonResult);
}
 
Example 11
Source File: CustomServiceApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
/**
 * 获取客服聊天记录
 */
public static ApiResult getRecord(String jsonStr) {
    String jsonResult = HttpKit.post(getRecordUrl + AccessTokenApi.getAccessTokenStr(), jsonStr);
    return new ApiResult(jsonResult);
}
 
Example 12
Source File: MenuApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
/**
 * 创建菜单
 */
public static ApiResult createMenu(String jsonStr) {
	String jsonResult = HttpKit.post(createMenu + AccessTokenApi.getAccessTokenStr(), jsonStr);
	return new ApiResult(jsonResult);
}
 
Example 13
Source File: CustomServiceApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
/**
 * 发送客服消息
 * @param message
 * @return ApiResult
 */
private static ApiResult sendMsg(Map<String, Object> message) {
    String accessToken = AccessTokenApi.getAccessTokenStr();
    String jsonResult = HttpKit.post(customMessageUrl + accessToken, JsonUtils.toJson(message));
    return new ApiResult(jsonResult);
}
 
Example 14
Source File: HttpExtKit.java    From jfinal-ext3 with Apache License 2.0 4 votes vote down vote up
/**
 * Send Hex String request
 */
public static String postHexString(String url, Map<String, String> queryParas, byte[] data, Map<String, String> headers) {
	return HttpKit.post(url, queryParas, HexKit.byteToHexString(data), headers);
}
 
Example 15
Source File: MessageApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
private static ApiResult post(String baseUrl, String jsonStr) {
	String url = baseUrl + AccessTokenApi.getAccessTokenStr();
	String jsonResult = HttpKit.post(url, jsonStr);
	return new ApiResult(jsonResult);
}
 
Example 16
Source File: SemanticApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
/**
 * 发送语义理解请求
 * @param jsonStr POST数据格式:JSON
 * @return ApiResult
 */
public static ApiResult search(String jsonStr) {
	String url = semanticUrl + AccessTokenApi.getAccessTokenStr();
	String jsonResult = HttpKit.post(url, jsonStr);
	return new ApiResult(jsonResult);
}
 
Example 17
Source File: ShorturlApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
public static ApiResult getShorturl(String jsonStr) {
	String jsonResult = HttpKit.post(apiUrl + AccessTokenApi.getAccessTokenStr(), jsonStr);
	return new ApiResult(jsonResult);
}
 
Example 18
Source File: QrcodeApi.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
public static ApiResult create(String jsonStr) {
	String jsonResult = HttpKit.post(apiUrl + AccessTokenApi.getAccessTokenStr(), jsonStr);
	return new ApiResult(jsonResult);
}
 
Example 19
Source File: HttpExtKit.java    From jfinal-ext3 with Apache License 2.0 4 votes vote down vote up
/**
 * Send byte data by post request
 */
public static String post(String url, Map<String, String> queryParas, byte[] data, Map<String, String> headers) {
	return HttpKit.post(url, queryParas, (new String(data)), headers);
}
 
Example 20
Source File: UserApi.java    From jfinal-weixin with Apache License 2.0 2 votes vote down vote up
/**
 * 批量获取用户基本信息, by Unas
 * @param jsonStr json字符串
 * @return ApiResult
 */
public static ApiResult batchGetUserInfo(String jsonStr) {
	String jsonResult = HttpKit.post(batchGetUserInfo + AccessTokenApi.getAccessTokenStr(), jsonStr);
	return new ApiResult(jsonResult);
}