當前位置: 首頁>>代碼示例>>Java>>正文


Java WxUtil類代碼示例

本文整理匯總了Java中org.hamster.weixinmp.util.WxUtil的典型用法代碼示例。如果您正苦於以下問題:Java WxUtil類的具體用法?Java WxUtil怎麽用?Java WxUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WxUtil類屬於org.hamster.weixinmp.util包,在下文中一共展示了WxUtil類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createRespText

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
public WxRespTextEntity createRespText(String content, String fromUserName,
		String toUserName, Integer funcFlag) {
	WxRespTextEntity respText = new WxRespTextEntity();
	respText.setContent(content);
	respText.setCreatedDate(new Date());
	respText.setCreateTime(WxUtil.currentTimeInSec());
	respText.setFromUserName(fromUserName);
	respText.setToUserName(toUserName);
	respText.setFuncFlag(funcFlag);
	respText.setMsgType(WxMsgRespType.TEXT);
	if (respTextDao != null) {
		respTextDao.save(respText);
	} else {

	}
	return respText;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:18,代碼來源:WxStorageService.java

示例2: createRespPicDesc

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
public WxRespPicDescEntity createRespPicDesc(
		List<WxItemPicDescEntity> articles, String fromUserName,
		String toUserName, Integer funcFlag) {
	WxRespPicDescEntity respPicDesc = new WxRespPicDescEntity();
	respPicDesc.setCreatedDate(new Date());
	respPicDesc.setCreateTime(WxUtil.currentTimeInSec());
	respPicDesc.setFromUserName(fromUserName);
	respPicDesc.setToUserName(toUserName);
	respPicDesc.setFuncFlag(funcFlag);
	respPicDesc.setMsgType(WxMsgRespType.NEWS);
	respPicDesc.setArticles(articles);
	if (respPicDescDao != null) {
		respPicDescDao.save(respPicDesc);
	} else {

	}
	return respPicDesc;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:19,代碼來源:WxStorageService.java

示例3: createRespPicDesc2

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
public WxRespPicDescEntity createRespPicDesc2(List<Long> articleIds,
		String fromUserName, String toUserName, Integer funcFlag) {
	WxRespPicDescEntity respPicDesc = new WxRespPicDescEntity();
	respPicDesc.setCreatedDate(new Date());
	respPicDesc.setCreateTime(WxUtil.currentTimeInSec());
	respPicDesc.setFromUserName(fromUserName);
	respPicDesc.setToUserName(toUserName);
	respPicDesc.setFuncFlag(funcFlag);
	respPicDesc.setMsgType(WxMsgRespType.NEWS);
	respPicDesc.setArticles(wxItemPicDescDao.findByIdIn(articleIds));
	if (respPicDescDao != null) {
		respPicDescDao.save(respPicDesc);
	} else {

	}
	return respPicDesc;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:18,代碼來源:WxStorageService.java

示例4: createRespMusic

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
public WxRespMusicEntity createRespMusic(String fromUserName,
		String toUserName, Integer funcFlag, WxItemMusicEntity itemMusic) {
	WxRespMusicEntity respMusic = new WxRespMusicEntity();
	respMusic.setCreatedDate(new Date());
	respMusic.setCreateTime(WxUtil.currentTimeInSec());
	respMusic.setFromUserName(fromUserName);
	respMusic.setToUserName(toUserName);
	respMusic.setFuncFlag(funcFlag);
	respMusic.setMsgType(WxMsgRespType.MUSIC);
	// respMusic.setMusic(itemMusic);
	if (respMusicDao != null) {
		respMusicDao.save(respMusic);
	} else {

	}
	return respMusic;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:18,代碼來源:WxStorageService.java

示例5: respEntityFactory

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
private static Element respEntityFactory(WxBaseRespEntity entity) {
	Element ele = DocumentHelper.createElement("xml");
	ele.addElement("ToUserName").addCDATA(entity.getToUserName());
	ele.addElement("FromUserName").addCDATA(entity.getFromUserName());
	String createTime = String.valueOf(entity.getCreateTime());
	if (StringUtils.isBlank(createTime)) {
		Long currentTime = WxUtil.currentTimeInSec();
		entity.setCreateTime(currentTime);
		createTime = String.valueOf(currentTime);
	}
	ele.addElement("CreateTime").setText(createTime);
	ele.addElement("MsgType").addCDATA(entity.getMsgType());
	ele.addElement("FuncFlag").setText(String.valueOf(entity.getFuncFlag()));
	return ele;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:16,代碼來源:WxXmlUtil.java

示例6: getAccessToken

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
public WxAuth getAccessToken(String appid, String appsecret)
		throws WxException {
	Map<String, String> paramsJson = new HashMap<String, String>();
	paramsJson.put("grant_type", "client_credential");
	paramsJson.put("appid", appid);
	paramsJson.put("secret", appsecret);

	WxAuth result = WxUtil.sendRequest(config.getAccessTokenCreateUrl(),
			HttpMethod.GET, paramsJson, null, WxAuth.class);
	result.setGrantType("client_credential");
	result.setAppid(appid);
	result.setSecret(appsecret);
	return result;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:15,代碼來源:WxAuthService.java

示例7: remoteMediaUpload

import org.hamster.weixinmp.util.WxUtil; //導入依賴的package包/類
public WxBaseItemMediaEntity remoteMediaUpload(String accessToken,
		WxMediaTypeEnum type, byte[] content) throws WxException {
	MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
	String typeString = null;
	switch (type) {
	case IMAGE:
	case THUMB:
	case VIDEO:
	case VOICE:
		typeString = type.toString().toLowerCase();
		break;
	case MUSIC:
	case DEFAULT:
	case PIC_DESC:
		throw new WxException("Not supported upload type : "
				+ type.toString());
	default:
		break;
	}

	Map<String, String> params = WxUtil.getAccessTokenParams(accessToken);
	System.out.println(typeString);
	params.put("type", typeString);
	ContentBody contentBody = new ByteArrayBody(content, ContentType.MULTIPART_FORM_DATA, "name.jpg");
	entityBuilder.addPart("media", contentBody);
	MediaResultMapper result = WxUtil.sendRequest(
			config.getMediaUploadUrl(), HttpMethod.POST, params,
			entityBuilder.build(), MediaResultMapper.class);

	WxBaseItemMediaEntity resultEntity = null;
	switch (type) {
	case IMAGE:
		WxItemImageEntity imageEntity = new WxItemImageEntity();
		imageEntity.setMediaId(result.getMedia_id());
		imageEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
		resultEntity = imageEntity;
		break;
	case THUMB:
		WxItemThumbEntity thumbEntity = new WxItemThumbEntity();
		thumbEntity.setMediaId(result.getMedia_id());
		thumbEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
		resultEntity = thumbEntity;
		break;
	case VIDEO:
		WxItemVideoEntity videoEntity = new WxItemVideoEntity();
		videoEntity.setMediaId(result.getMedia_id());
		videoEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
		resultEntity = videoEntity;
		break;
	case VOICE:
		WxItemVoiceEntity voiceEntity = new WxItemVoiceEntity();
		voiceEntity.setMediaId(result.getMedia_id());
		voiceEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
		resultEntity = voiceEntity;
		break;
	case MUSIC:
	case DEFAULT:
	case PIC_DESC:
		throw new WxException("Not supported upload type : "
				+ type.toString());
	default:
		break;
	}
	return resultEntity;
}
 
開發者ID:Charlemin,項目名稱:weixin-mp-java-master,代碼行數:66,代碼來源:WxMediaService.java


注:本文中的org.hamster.weixinmp.util.WxUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。