当前位置: 首页>>代码示例>>Java>>正文


Java WxMpCustomMessage类代码示例

本文整理汇总了Java中me.chanjar.weixin.mp.bean.WxMpCustomMessage的典型用法代码示例。如果您正苦于以下问题:Java WxMpCustomMessage类的具体用法?Java WxMpCustomMessage怎么用?Java WxMpCustomMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WxMpCustomMessage类属于me.chanjar.weixin.mp.bean包,在下文中一共展示了WxMpCustomMessage类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onError

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
public void onError(SpeechError error) {
	WxMpCustomMessage message = WxMpCustomMessage.TEXT().content("echo:"+wxMessage.getContent())
	        .toUser(wxMessage.getFromUserName()).build();;
	try {
		wxMpService.customMessageSend(message);
	} catch (WxErrorException e) {
		LOGGER.error("Failed to send custom message", e);
	}
	LOGGER.error("Failed to recognize content" + error.toString(), error.getCause());
}
 
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:11,代码来源:CustomTextUnderstanderListener.java

示例2: customMessageSend

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public boolean customMessageSend(WxMpCustomMessage message)
    throws WxErrorException {
  String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send";
  String responseContent = this.wxMpService.post(url, message.toJson());
  return responseContent != null;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:8,代码来源:WxMpKefuServiceImpl.java

示例3: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public WxMpCustomMessage build() {
  WxMpCustomMessage m = super.build();
  m.setMediaId(this.mediaId);
  m.setTitle(this.title);
  m.setDescription(this.description);
  m.setThumbMediaId(this.thumbMediaId);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:10,代码来源:VideoBuilder.java

示例4: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public WxMpCustomMessage build() {
  WxMpCustomMessage m = super.build();
  m.setMusicUrl(this.musicUrl);
  m.setHqMusicUrl(this.hqMusicUrl);
  m.setTitle(this.title);
  m.setDescription(this.description);
  m.setThumbMediaId(this.thumbMediaId);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:11,代码来源:MusicBuilder.java

示例5: testSendCustomMessage

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
public void testSendCustomMessage() throws WxErrorException {
  WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService
      .getWxMpConfigStorage();
  WxMpCustomMessage message = new WxMpCustomMessage();
  message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
  message.setToUser(configStorage.getOpenid());
  message.setContent(
      "欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");

  this.wxService.getKefuService().customMessageSend(message);
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:12,代码来源:WxMpKefuServiceImplTest.java

示例6: testSendCustomMessageWithKfAccount

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
public void testSendCustomMessageWithKfAccount() throws WxErrorException {
  WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService
      .getWxMpConfigStorage();
  WxMpCustomMessage message = new WxMpCustomMessage();
  message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
  message.setToUser(configStorage.getOpenid());
  message.setKfAccount(configStorage.getKfAccount());
  message.setContent(
      "欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");

  this.wxService.getKefuService().customMessageSend(message);
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:13,代码来源:WxMpKefuServiceImplTest.java

示例7: onResult

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
public void onResult(UnderstanderResult result) {
	String resultString = result.getResultString();
	LOGGER.info("onResult = " + resultString);
	
	ObjectMapper objectMapper = new ObjectMapper();
	try {
		SemanticResponse response = objectMapper.readValue(resultString, SemanticResponse.class);
		if (response.getRc() == 0) {
			Semantic sematic = response.getSemantic();
			Slots slots = sematic.getSlots();
			if(slots.getStartLoc()!=null && slots.getEndLoc()!=null && slots.getStartDate()!=null) {
				String fromCity = CityToAirportCode.toCode(slots.getStartLoc().getCityAddr());
				String toCity = CityToAirportCode.toCode(slots.getEndLoc().getCityAddr());
				LOGGER.info("fromCity = {}, toCity = {}",fromCity,toCity);
				if(fromCity == null) {
					fromCity = "SHA";
				}
				if(toCity == null) {
					toCity = "BJS";
				}
				String fromDate = slots.getStartDate().getDate();
				String request = "{  \"fromCity\": \""+fromCity+"\",  \"toCity\": \""+toCity+"\",  \"fromDate\": \"" + fromDate +"\",  \"sort\": \"date\",  \"spName\":\"tdx\",  \"orderRule\":\"asc\",  \"userToken\":\""
						+ this.flight_user_token+"\",  \"operation\": \"SEARCHLOWEST\" } ";
				RestTemplate rt = new RestTemplate();
				// 机票搜索服务
				String stringResponse =  rt.postForObject(this.flight_search_url, request, String.class);
				stringResponse = new String(stringResponse.getBytes("ISO-8859-1"), "UTF-8");
				
				FlightSearchResponse flightSearchResponse = objectMapper.readValue(stringResponse, FlightSearchResponse.class);
				if(flightSearchResponse.getRescode().equals("0")) {
					List<FlightSchedule> schedules = flightSearchResponse.getFlightSchedules();
					
					WxMpCustomMessage.WxArticle article1 = new WxMpCustomMessage.WxArticle();
					article1.setUrl("#");
					article1.setPicUrl("http://pngimg.com/upload/plane_PNG5249.png");
					article1.setDescription("总共"+schedules.size()+"条航班");
					article1.setTitle(slots.getStartLoc().getCityAddr()+"到"+slots.getEndLoc().getCityAddr()+"的前5条航班");
					List<WxMpCustomMessage.WxArticle> articles = new ArrayList<>();
					articles.add(article1);
					
					for (int i = 0; i < schedules.size() && i < 5; i++) {
						FlightSchedule flightSchedule = schedules.get(i);
						String line = flightSchedule.getAirlineCompany() +" - " +flightSchedule.getFlightNo() +" - ¥:"+ flightSchedule.getLowestPrice()
						+" - 起飞:"+ flightSchedule.getFromDate().substring(0,flightSchedule.getFromDate().indexOf(".")) 
						+" - 到达:"+ flightSchedule.getToDate().substring(0,flightSchedule.getToDate().indexOf(".")) ;
						
						WxMpCustomMessage.WxArticle article2 = new WxMpCustomMessage.WxArticle();
						article2.setUrl("#");
						article2.setPicUrl("http://pngimg.com/upload/plane_PNG5249.png");
						article2.setDescription("确认订票?");
						article2.setTitle(line);
						articles.add(article2);
						
					}
					NewsBuilder builder = WxMpCustomMessage.NEWS().toUser(wxMessage.getFromUserName());
					for (WxMpCustomMessage.WxArticle wxArticle : articles) {
						builder.addArticle(wxArticle);
					}
					WxMpCustomMessage message = builder.build();
					// 设置消息的内容等信息
					wxMpService.customMessageSend(message);
					
				}  else {
					LOGGER.error(flightSearchResponse.toString());
				}
			} else {
				LOGGER.equals(slots.toString());
			}
		}
	} catch (WxErrorException e) {
		LOGGER.error("Failed to send custom message", e);
	}catch (Exception e1) {
		LOGGER.error("Unexpected exception", e1);
	} 
}
 
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:76,代码来源:CustomTextUnderstanderListener.java

示例8: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public WxMpCustomMessage build() {
  WxMpCustomMessage m = super.build();
  m.setMediaId(this.mediaId);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:7,代码来源:ImageBuilder.java

示例9: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public WxMpCustomMessage build() {
  WxMpCustomMessage m = super.build();
  m.setCardId(this.cardId);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:7,代码来源:WxCardBuilder.java

示例10: addArticle

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
public NewsBuilder addArticle(WxMpCustomMessage.WxArticle article) {
  this.articles.add(article);
  return this;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:5,代码来源:NewsBuilder.java

示例11: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public WxMpCustomMessage build() {
  WxMpCustomMessage m = super.build();
  m.setArticles(this.articles);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:7,代码来源:NewsBuilder.java

示例12: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
@Override
public WxMpCustomMessage build() {
  WxMpCustomMessage m = super.build();
  m.setContent(this.content);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:7,代码来源:TextBuilder.java

示例13: build

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
public WxMpCustomMessage build() {
  WxMpCustomMessage m = new WxMpCustomMessage();
  m.setMsgType(this.msgType);
  m.setToUser(this.toUser);
  return m;
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:7,代码来源:BaseBuilder.java

示例14: customMessageSend

import me.chanjar.weixin.mp.bean.WxMpCustomMessage; //导入依赖的package包/类
/**
 * <pre>
 * 发送客服消息
 * 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547&token=&lang=zh_CN">发送客服消息</a>
 * </pre>
 */
boolean customMessageSend(WxMpCustomMessage message) throws WxErrorException;
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:8,代码来源:WxMpKefuService.java


注:本文中的me.chanjar.weixin.mp.bean.WxMpCustomMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。