国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
微信開發(fā)總結(jié) 二

1.發(fā)送,接受消息的常量

  1. public class MessageConstant {  
  2.       
  3.     /**文本 */   
  4.     public static final String REQ_MESSAGE_TYPE_TEXT = "text";    
  5.     /**圖片*/  
  6.     public static final String REQ_MESSAGE_TYPE_IMAGE = "image";    
  7.     /**語音*/  
  8.     public static final String REQ_MESSAGE_TYPE_VOICE = "voice";   
  9.     /**視頻*/  
  10.     public static final String REQ_MESSAGE_TYPE_VIDEO = "video";  
  11.     /**小視頻*/  
  12.     public static final String REQ_MESSAGE_TYPE_SHORTVIDEO = "shortvideo";  
  13.     /**地理位置*/   
  14.     public static final String REQ_MESSAGE_TYPE_LOCATION = "location";    
  15.     /**鏈接消息*/   
  16.     public static final String REQ_MESSAGE_TYPE_LINK = "link";    
  17.     
  18.       
  19.     /** 事件類型:subscribe(訂閱)*/    
  20.     public static final String EVENT_TYPE_SUBSCRIBE = "subscribe";    
  21.     /**事件類型:unsubscribe(取消訂閱)*/    
  22.     public static final String EVENT_TYPE_UNSUBSCRIBE = "unsubscribe";   
  23.     /**二維碼掃描*/   
  24.     public static final String EVENT_TYPE_SCAN = "SCAN";    
  25.     /**位置類型*/  
  26.     public static final String EVENT_TYPE_LOCATION  = "LOCATION";    
  27.     /**事件類型:CLICK(自定義菜單點擊事件)*/    
  28.     public static final String EVENT_TYPE_CLICK = "CLICK";    
  29.       
  30.     /**文本 */   
  31.     public static final String RES_MESSAGE_TYPE_TEXT = "text";  
  32.     /**圖片*/  
  33.     public static final String RES_MESSAGE_TYPE_IMAGE = "image";    
  34.     /**語音*/  
  35.     public static final String RES_MESSAGE_TYPE_VOICE = "voice";   
  36.     /**視頻*/  
  37.     public static final String RES_MESSAGE_TYPE_VIDEO = "video";  
  38.     /**音樂*/  
  39.     public static final String RES_MESSAGE_TYPE_MUSIC = "music";  
  40.     /**圖文*/  
  41.     public static final String RES_MESSAGE_TYPE_NEWS = "news";  
  42.       
  43. }  



messageUtil:處理json

  1. public class MessageUtil {  
  2.     /** 
  3.      * 解析微信發(fā)來的請求(xml) 
  4.      * @author wuyw 
  5.      * 2015-7-29下午6:11:41 
  6.      * @return 
  7.      */  
  8.     public static Map<String,String> parseXml(HttpServletRequest request){  
  9.         Map<String,String> map = new HashMap<String,String>();  
  10.         try {  
  11.             //獲取微信傳來的參數(shù)  
  12.             InputStream inputStream = request.getInputStream();  
  13.             //讀取輸入流  
  14.             SAXReader reader = new SAXReader();  
  15.             Document document = reader.read(inputStream);  
  16.             //獲取xml根元素  
  17.             Element root = document.getRootElement();  
  18.             @SuppressWarnings("unchecked")  
  19.             List<Element> elements = root.elements();  
  20.             //遍歷獲取的元素  
  21.             for (Element element : elements) {  
  22.                 map.put(element.getName(), element.getText());  
  23.             }  
  24.             inputStream.close();  
  25.         } catch (Exception e) {  
  26.             e.printStackTrace();  
  27.         }  
  28.         return map;  
  29.     }  
  30.       
  31.     /** 
  32.      * 擴展xstream令其支持CDATA 
  33.      */  
  34.     public static XStream xStream=new XStream(new XppDriver(){  
  35.         public HierarchicalStreamWriter createWriter(Writer out){  
  36.             return new PrettyPrintWriter(out){  
  37.                 //對所有xml增加CDATA標記  
  38.                 boolean cdata=true;  
  39.                   
  40.                 @SuppressWarnings("rawtypes")  
  41.                 public void startNode(String name, Class clazz){  
  42.                     super.startNode(name, clazz);  
  43.                 }  
  44.                   
  45.                 protected void writeText(QuickWriter writer, String text){  
  46.                     if(cdata){  
  47.                         writer.write("<![CDATA[");  
  48.                         writer.write(text);  
  49.                         writer.write("]]>");  
  50.                     }else{  
  51.                         writer.write(text);  
  52.                     }  
  53.                 }  
  54.             };  
  55.         }  
  56.     });  
  57.     //文本  
  58.     public static String messageToXml(BaseResMsg resMsg){  
  59.         xStream.alias("xml", resMsg.getClass());  
  60.         return xStream.toXML(resMsg);  
  61.     }  
  62.       
  63. }  


本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
微信公眾賬號開發(fā)教程第4篇-消息及消息處理工具的封裝
源碼分析(1.4萬字) | Mybatis接口沒有實現(xiàn)類為什么可以執(zhí)行增刪改查
XML與JSON學(xué)習筆記分享
xstream實現(xiàn)JAVA對象和XML的相互轉(zhuǎn)化
xstream 解析xml 別名 注解 list集合 boolean 數(shù)組 converter Pom.xml設(shè)置
String和InputStream的轉(zhuǎn)換
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服