作者:烟台中海地产有限公司往 | 来源:互联网 | 2013-06-23 21:42
工欲善其事必先利其器!本篇内容主要讲解如何将微信公众平台定义的消息及消息相关的操作封装成工具类,方面后期的使用。这里需要明确的是消息其实是由用户发给你的公众帐号的,消息先被微信平台接收到,然后微信平台会将该消息转给你在开发模式接口配置中指定的URL地
工欲善其事必先利其器!本篇内容主要讲解如何将微信公众平台定义的消息及消息相关的操作封装成工具类,方面后期的使用。这里需要明确的是消息其实是由用户发给你的公众帐号的,消息先被微信平台接收到,然后微信平台会将该消息转给你在开发模式接口配置中指定的URL地址。
微信公众平台消息接口
要接收微信平台发送的消息,我们需要先熟悉微信公众平台API中消息接口部分,点此进入,点击后将进入到消息接口指南部分,如下图所示:
在上图左侧可以看到微信公众平台目前开放的接口有三种:消息接口、通用接口和自定义菜单接口。通用接口和自定义菜单接口只有拿到内测资格才能调用,而内测资格的申请也已经关闭了,我们只有期待将来某一天微信会对大众用户开放吧,所以没有内测资格的用户就不要再浪费时间在这两个接口上,只需要用好消息接口就可以了。
消息推送和消息回复
下面将主要介绍消息接口。对于消息的接收、响应我们只需要关注上图中的“4 消息推送”和“5 消息回复”就足够了。
我们先来了解接口中的“消息推送”指的是什么,点击“4 消息推送”,可以看到接口中的“消息推送”指的是“当普通用户向公众帐号发消息时,微信服务器将POST该消息到填写的URL上”,即这里定义的是用户能够发送哪些类型的消息、消息有哪些字段、消息被微信服务器以什么方式转发给我们的公众帐号后台。
消息推送中定义了我们将会接收到的消息类型有5种:文本消息、图片消息、地理位置消息、链接消息和事件推送,其实语音消息我们也能够接收到的,只不过拿不到具体的语音文件而以(需要内测资格才能够获取语音文件)。
接口中的“消息回复”定义了我们能回复给用户的消息类型、消息字段和消息格式,微信公众平台的接口指南中是这样描述的:
上面说到我们能回复给用户的消息有5种,但目前在开发模式下能回复的消息只有3种:文本消息、音乐消息和图文消息,而语音消息和视频消息目前只能在编辑模式下使用。
消息的封装
接下来要做的就是将消息推送(请求)、消息回复(响应)中定义的消息进行封装,建立与之对应的Java类(Java是一门面向对象的编程语言,封装后使用起来更方便),下面的请求消息是指消息推送中定义的消息,响应消息指消息回复中定义的消息。
请求消息的基类
把消息推送中定义的所有消息都有的字段提取出来,封装成一个基类,这些公有的字段包括:ToUserName(开发者微信号)、FromUserName(发送方帐号,OPEN_ID)、CreateTime(消息的创建时间)、MsgType(消息类型)、MsgId(消息ID),封装后基类org.liufeng.course.message.req.BaseMessage的代码如下:
[java] view plaincopyprint?
-
package org.liufeng.course.message.req;
-
-
/**
-
* 消息基类(普通用户 -> 公众帐号)
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class BaseMessage {
-
// 开发者微信号
-
private String ToUserName;
-
// 发送方帐号(一个OpenID)
-
private String FromUserName;
-
// 消息创建时间 (整型)
-
private long CreateTime;
-
// 消息类型(text/image/location/link)
-
private String MsgType;
-
// 消息id,64位整型
-
private long MsgId;
-
-
public String getToUserName() {
-
return ToUserName;
-
}
-
-
public void setToUserName(String toUserName) {
-
ToUserName = toUserName;
-
}
-
-
public String getFromUserName() {
-
return FromUserName;
-
}
-
-
public void setFromUserName(String fromUserName) {
-
FromUserName = fromUserName;
-
}
-
-
public long getCreateTime() {
-
return CreateTime;
-
}
-
-
public void setCreateTime(long createTime) {
-
CreateTime = createTime;
-
}
-
-
public String getMsgType() {
-
return MsgType;
-
}
-
-
public void setMsgType(String msgType) {
-
MsgType = msgType;
-
}
-
-
public long getMsgId() {
-
return MsgId;
-
}
-
-
public void setMsgId(long msgId) {
-
MsgId = msgId;
-
}
-
}
package org.liufeng.course.message.req;
/**
* 消息基类(普通用户 -> 公众帐号)
*
* @author liufeng
* @date 2013-05-19
*/
public class BaseMessage {
// 开发者微信号
private String ToUserName;
// 发送方帐号(一个OpenID)
private String FromUserName;
// 消息创建时间 (整型)
private long CreateTime;
// 消息类型(text/image/location/link)
private String MsgType;
// 消息id,64位整型
private long MsgId;
public String getToUserName() {
return ToUserName;
}
public void setToUserName(String toUserName) {
ToUserName = toUserName;
}
public String getFromUserName() {
return FromUserName;
}
public void setFromUserName(String fromUserName) {
FromUserName = fromUserName;
}
public long getCreateTime() {
return CreateTime;
}
public void setCreateTime(long createTime) {
CreateTime = createTime;
}
public String getMsgType() {
return MsgType;
}
public void setMsgType(String msgType) {
MsgType = msgType;
}
public long getMsgId() {
return MsgId;
}
public void setMsgId(long msgId) {
MsgId = msgId;
}
}
请求消息之文本消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.req;
-
-
/**
-
* 文本消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class TextMessage extends BaseMessage {
-
// 消息内容
-
private String Content;
-
-
public String getContent() {
-
return Content;
-
}
-
-
public void setContent(String content) {
-
COntent= content;
-
}
-
}
package org.liufeng.course.message.req;
/**
* 文本消息
*
* @author liufeng
* @date 2013-05-19
*/
public class TextMessage extends BaseMessage {
// 消息内容
private String Content;
public String getContent() {
return Content;
}
public void setContent(String content) {
COntent= content;
}
}
请求消息之图片消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.req;
-
-
/**
-
* 图片消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class ImageMessage extends BaseMessage {
-
// 图片链接
-
private String PicUrl;
-
-
public String getPicUrl() {
-
return PicUrl;
-
}
-
-
public void setPicUrl(String picUrl) {
-
PicUrl = picUrl;
-
}
-
}
package org.liufeng.course.message.req;
/**
* 图片消息
*
* @author liufeng
* @date 2013-05-19
*/
public class ImageMessage extends BaseMessage {
// 图片链接
private String PicUrl;
public String getPicUrl() {
return PicUrl;
}
public void setPicUrl(String picUrl) {
PicUrl = picUrl;
}
}
请求消息之地理位置消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.req;
-
-
/**
-
* 地理位置消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class LocationMessage extends BaseMessage {
-
// 地理位置维度
-
private String Location_X;
-
// 地理位置经度
-
private String Location_Y;
-
// 地图缩放大小
-
private String Scale;
-
// 地理位置信息
-
private String Label;
-
-
public String getLocation_X() {
-
return Location_X;
-
}
-
-
public void setLocation_X(String location_X) {
-
Location_X = location_X;
-
}
-
-
public String getLocation_Y() {
-
return Location_Y;
-
}
-
-
public void setLocation_Y(String location_Y) {
-
Location_Y = location_Y;
-
}
-
-
public String getScale() {
-
return Scale;
-
}
-
-
public void setScale(String scale) {
-
Scale = scale;
-
}
-
-
public String getLabel() {
-
return Label;
-
}
-
-
public void setLabel(String label) {
-
Label = label;
-
}
-
}
package org.liufeng.course.message.req;
/**
* 地理位置消息
*
* @author liufeng
* @date 2013-05-19
*/
public class LocationMessage extends BaseMessage {
// 地理位置维度
private String Location_X;
// 地理位置经度
private String Location_Y;
// 地图缩放大小
private String Scale;
// 地理位置信息
private String Label;
public String getLocation_X() {
return Location_X;
}
public void setLocation_X(String location_X) {
Location_X = location_X;
}
public String getLocation_Y() {
return Location_Y;
}
public void setLocation_Y(String location_Y) {
Location_Y = location_Y;
}
public String getScale() {
return Scale;
}
public void setScale(String scale) {
Scale = scale;
}
public String getLabel() {
return Label;
}
public void setLabel(String label) {
Label = label;
}
}
请求消息之链接消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.req;
-
-
/**
-
* 链接消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class LinkMessage extends BaseMessage {
-
// 消息标题
-
private String Title;
-
// 消息描述
-
private String Description;
-
// 消息链接
-
private String Url;
-
-
public String getTitle() {
-
return Title;
-
}
-
-
public void setTitle(String title) {
-
Title = title;
-
}
-
-
public String getDescription() {
-
return Description;
-
}
-
-
public void setDescription(String description) {
-
Description = description;
-
}
-
-
public String getUrl() {
-
return Url;
-
}
-
-
public void setUrl(String url) {
-
Url = url;
-
}
-
}
package org.liufeng.course.message.req;
/**
* 链接消息
*
* @author liufeng
* @date 2013-05-19
*/
public class LinkMessage extends BaseMessage {
// 消息标题
private String Title;
// 消息描述
private String Description;
// 消息链接
private String Url;
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
public String getDescription() {
return Description;
}
public void setDescription(String description) {
Description = description;
}
public String getUrl() {
return Url;
}
public void setUrl(String url) {
Url = url;
}
}
请求消息之语音消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.req;
-
-
/**
-
* 音频消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class VoiceMessage extends BaseMessage {
-
// 媒体ID
-
private String MediaId;
-
// 语音格式
-
private String Format;
-
-
public String getMediaId() {
-
return MediaId;
-
}
-
-
public void setMediaId(String mediaId) {
-
MediaId = mediaId;
-
}
-
-
public String getFormat() {
-
return Format;
-
}
-
-
public void setFormat(String format) {
-
Format = format;
-
}
-
}
package org.liufeng.course.message.req;
/**
* 音频消息
*
* @author liufeng
* @date 2013-05-19
*/
public class VoiceMessage extends BaseMessage {
// 媒体ID
private String MediaId;
// 语音格式
private String Format;
public String getMediaId() {
return MediaId;
}
public void setMediaId(String mediaId) {
MediaId = mediaId;
}
public String getFormat() {
return Format;
}
public void setFormat(String format) {
Format = format;
}
}
响应消息的基类
同样,把消息回复中定义的所有消息都有的字段提取出来,封装成一个基类,这些公有的字段包括:ToUserName(接收方帐号,用户的OPEN_ID)、FromUserName(开发者的微信号)、CreateTime(消息的创建时间)、MsgType(消息类型)、FuncFlag(消息的星标标识),封装后基类org.liufeng.course.message.resp.BaseMessage的代码如下:
[java] view plaincopyprint?
-
package org.liufeng.course.message.resp;
-
-
/**
-
* 消息基类(公众帐号 -> 普通用户)
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class BaseMessage {
-
// 接收方帐号(收到的OpenID)
-
private String ToUserName;
-
// 开发者微信号
-
private String FromUserName;
-
// 消息创建时间 (整型)
-
private long CreateTime;
-
// 消息类型(text/music/news)
-
private String MsgType;
-
// 位0x0001被标志时,星标刚收到的消息
-
private int FuncFlag;
-
-
public String getToUserName() {
-
return ToUserName;
-
}
-
-
public void setToUserName(String toUserName) {
-
ToUserName = toUserName;
-
}
-
-
public String getFromUserName() {
-
return FromUserName;
-
}
-
-
public void setFromUserName(String fromUserName) {
-
FromUserName = fromUserName;
-
}
-
-
public long getCreateTime() {
-
return CreateTime;
-
}
-
-
public void setCreateTime(long createTime) {
-
CreateTime = createTime;
-
}
-
-
public String getMsgType() {
-
return MsgType;
-
}
-
-
public void setMsgType(String msgType) {
-
MsgType = msgType;
-
}
-
-
public int getFuncFlag() {
-
return FuncFlag;
-
}
-
-
public void setFuncFlag(int funcFlag) {
-
FuncFlag = funcFlag;
-
}
-
}
package org.liufeng.course.message.resp;
/**
* 消息基类(公众帐号 -> 普通用户)
*
* @author liufeng
* @date 2013-05-19
*/
public class BaseMessage {
// 接收方帐号(收到的OpenID)
private String ToUserName;
// 开发者微信号
private String FromUserName;
// 消息创建时间 (整型)
private long CreateTime;
// 消息类型(text/music/news)
private String MsgType;
// 位0x0001被标志时,星标刚收到的消息
private int FuncFlag;
public String getToUserName() {
return ToUserName;
}
public void setToUserName(String toUserName) {
ToUserName = toUserName;
}
public String getFromUserName() {
return FromUserName;
}
public void setFromUserName(String fromUserName) {
FromUserName = fromUserName;
}
public long getCreateTime() {
return CreateTime;
}
public void setCreateTime(long createTime) {
CreateTime = createTime;
}
public String getMsgType() {
return MsgType;
}
public void setMsgType(String msgType) {
MsgType = msgType;
}
public int getFuncFlag() {
return FuncFlag;
}
public void setFuncFlag(int funcFlag) {
FuncFlag = funcFlag;
}
}
响应消息之文本消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.resp;
-
-
/**
-
* 文本消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class TextMessage extends BaseMessage {
-
// 回复的消息内容
-
private String Content;
-
-
public String getContent() {
-
return Content;
-
}
-
-
public void setContent(String content) {
-
COntent= content;
-
}
-
}
package org.liufeng.course.message.resp;
/**
* 文本消息
*
* @author liufeng
* @date 2013-05-19
*/
public class TextMessage extends BaseMessage {
// 回复的消息内容
private String Content;
public String getContent() {
return Content;
}
public void setContent(String content) {
COntent= content;
}
}
响应消息之音乐消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.resp;
-
-
/**
-
* 音乐消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class MusicMessage extends BaseMessage {
-
// 音乐
-
private Music Music;
-
-
public Music getMusic() {
-
return Music;
-
}
-
-
public void setMusic(Music music) {
-
Music = music;
-
}
-
}
package org.liufeng.course.message.resp;
/**
* 音乐消息
*
* @author liufeng
* @date 2013-05-19
*/
public class MusicMessage extends BaseMessage {
// 音乐
private Music Music;
public Music getMusic() {
return Music;
}
public void setMusic(Music music) {
Music = music;
}
}
音乐消息中Music类的定义
[java] view plaincopyprint?
-
package org.liufeng.course.message.resp;
-
-
/**
-
* 音乐model
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class Music {
-
// 音乐名称
-
private String Title;
-
// 音乐描述
-
private String Description;
-
// 音乐链接
-
private String MusicUrl;
-
// 高质量音乐链接,WIFI环境优先使用该链接播放音乐
-
private String HQMusicUrl;
-
-
public String getTitle() {
-
return Title;
-
}
-
-
public void setTitle(String title) {
-
Title = title;
-
}
-
-
public String getDescription() {
-
return Description;
-
}
-
-
public void setDescription(String description) {
-
Description = description;
-
}
-
-
public String getMusicUrl() {
-
return MusicUrl;
-
}
-
-
public void setMusicUrl(String musicUrl) {
-
MusicUrl = musicUrl;
-
}
-
-
public String getHQMusicUrl() {
-
return HQMusicUrl;
-
}
-
-
public void setHQMusicUrl(String musicUrl) {
-
HQMusicUrl = musicUrl;
-
}
-
-
}
package org.liufeng.course.message.resp;
/**
* 音乐model
*
* @author liufeng
* @date 2013-05-19
*/
public class Music {
// 音乐名称
private String Title;
// 音乐描述
private String Description;
// 音乐链接
private String MusicUrl;
// 高质量音乐链接,WIFI环境优先使用该链接播放音乐
private String HQMusicUrl;
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
public String getDescription() {
return Description;
}
public void setDescription(String description) {
Description = description;
}
public String getMusicUrl() {
return MusicUrl;
}
public void setMusicUrl(String musicUrl) {
MusicUrl = musicUrl;
}
public String getHQMusicUrl() {
return HQMusicUrl;
}
public void setHQMusicUrl(String musicUrl) {
HQMusicUrl = musicUrl;
}
}
响应消息之图文消息
[java] view plaincopyprint?
-
package org.liufeng.course.message.resp;
-
-
import java.util.List;
-
-
/**
-
* 文本消息
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class NewsMessage extends BaseMessage {
-
// 图文消息个数,限制为10条以内
-
private int ArticleCount;
-
// 多条图文消息信息,默认第一个item为大图
-
private List Articles;
-
-
public int getArticleCount() {
-
return ArticleCount;
-
}
-
-
public void setArticleCount(int articleCount) {
-
ArticleCount = articleCount;
-
}
-
-
public List getArticles() {
-
return Articles;
-
}
-
-
public void setArticles(List articles) {
-
Articles = articles;
-
}
-
}
package org.liufeng.course.message.resp;
import java.util.List;
/**
* 文本消息
*
* @author liufeng
* @date 2013-05-19
*/
public class NewsMessage extends BaseMessage {
// 图文消息个数,限制为10条以内
private int ArticleCount;
// 多条图文消息信息,默认第一个item为大图
private List Articles;
public int getArticleCount() {
return ArticleCount;
}
public void setArticleCount(int articleCount) {
ArticleCount = articleCount;
}
public List getArticles() {
return Articles;
}
public void setArticles(List articles) {
Articles = articles;
}
}
图文消息中Article类的定义
[java] view plaincopyprint?
-
package org.liufeng.course.message.resp;
-
-
/**
-
* 图文model
-
*
-
* @author liufeng
-
* @date 2013-05-19
-
*/
-
public class Article {
-
// 图文消息名称
-
private String Title;
-
// 图文消息描述
-
private String Description;
-
// 图片链接,支持JPG、PNG格式,较好的效果为大图640*320,小图80*80,限制图片链接的域名需要与开发者填写的基本资料中的Url一致
-
private String PicUrl;
-
// 点击图文消息跳转链接
-
private String Url;
-
-
public String getTitle() {
-
return Title;
-
}
-
-
public void setTitle(String title) {
-
Title = title;
-
}
-
-
public String getDescription() {
-
return null == Description ? "" : Description;
-
}
-
-
public void setDescription(String description) {
-
Description = description;
-
}
-
-
public String getPicUrl() {
-
return null == PicUrl ? "" : PicUrl;
-
}
-
-
public void setPicUrl(String picUrl) {
-
PicUrl = picUrl;
-
}
-
-
public String getUrl() {
-
return null == Url ? "" : Url;
-
}
-
-
public void setUrl(String url) {
-
Url = url;
-
}
-
-
}
package org.liufeng.course.message.resp;
/**
* 图文model
*
* @author liufeng
* @date 2013-05-19
*/
public class Article {
// 图文消息名称
private String Title;
// 图文消息描述
private String Description;
// 图片链接,支持JPG、PNG格式,较好的效果为大图640*320,小图80*80,限制图片链接的域名需要与开发者填写的基本资料中的Url一致
private String PicUrl;
// 点击图文消息跳转链接
private String Url;
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
public String getDescription() {
return null == Description ? "" : Description;
}
public void setDescription(String description) {
Description = description;
}
public String getPicUrl() {
return null == PicUrl ? "" : PicUrl;
}
public void setPicUrl(String picUrl) {
PicUrl = picUrl;
}
public String getUrl() {
return null == Url ? "" : Url;
}
public void setUrl(String url) {
Url = url;
}
}
全部消息封装完成后,Eclipse工程中关于消息部分的结构应该与下图保持一致,如果不一致的(类名、属性名称不一致的)请检查后调整一致,因为后面的章节还要介绍如何将微信开发中通用的类方法、与业务无关的工具类封装打成jar包,以后再做微信项目只需要引入该jar包即可,这种工作做一次就可以了。
如何解析请求消息?
接下来解决请求消息的解析问题。微信服务器会将用户的请求通过doPost方法发送给我们,让我们再来回顾下上一章节已经写好的doPost方法的定义:
[java] view plaincopyprint?
-
/**
-
* 处理微信服务器发来的消息
-
*/
-
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
// TODO 消息的接收、处理、响应
-
}
/**
* 处理微信服务器发来的消息
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO 消息的接收、处理、响应
}
doPost方法有两个参数,request中封装了请求相关的所有内容,可以从request中取出微信服务器发来的消息;而通过response我们可以对接收到的消息进行响应,即发送消息。
那么如何解析请求消息的问题也就转化为如何从request中得到微信服务器发送给我们的xml格式的消息了。这里我们借助于开源框架dom4j去解析xml(这里使用的是dom4j-1.6.1.jar),然后将解析得到的结果存入HashMap,解析请求消息的方法如下:
[java] view plaincopyprint?
-
/**
-
* 解析微信发来的请求(XML)
-
*
-
* @param request
-
* @return
-
* @throws Exception
-
*/
-
@SuppressWarnings("unchecked")
-
public static Map parseXml(HttpServletRequest request) throws Exception {
-
// 将解析结果存储在HashMap中
-
Map map = new HashMap();
-
-
// 从request中取得输入流
-
InputStream inputStream = request.getInputStream();
-
// 读取输入流
-
SAXReader reader = new SAXReader();
-
Document document = reader.read(inputStream);
-
// 得到xml根元素
-
Element root = document.getRootElement();
-
// 得到根元素的所有子节点
-
List elementList = root.elements();
-
-
// 遍历所有子节点
-
for (Element e : elementList)
-
map.put(e.getName(), e.getText());
-
-
// 释放资源
-
inputStream.close();
-
inputStream = null;
-
-
return map;
-
}
/**
* 解析微信发来的请求(XML)
*
* @param request
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static Map parseXml(HttpServletRequest request) throws Exception {
// 将解析结果存储在HashMap中
Map map = new HashMap();
// 从request中取得输入流
InputStream inputStream = request.getInputStream();
// 读取输入流
SAXReader reader = new SAXReader();
Document document = reader.read(inputStream);
// 得到xml根元素
Element root = document.getRootElement();
// 得到根元素的所有子节点
List elementList = root.elements();
// 遍历所有子节点
for (Element e : elementList)
map.put(e.getName(), e.getText());
// 释放资源
inputStream.close();
inputStream = null;
return map;
}
如何将响应消息转换成xml返回?
我们先前已经将响应消息封装成了Java类,方便我们在代码中使用。那么,请求接收成功、处理完成后,该如何将消息返回呢?这里就涉及到如何将响应消息转换成xml返回的问题,这里我们将采用开源框架xstream来实现Java类到xml的转换(这里使用的是xstream-1.3.1.jar),代码如下:
[java] view plaincopyprint?
-
/**
-
* 文本消息对象转换成xml
-
*
-
* @param textMessage 文本消息对象
-
* @return xml
-
*/
-
public static String textMessageToXml(TextMessage textMessage) {
-
xstream.alias("xml", textMessage.getClass());
-
return xstream.toXML(textMessage);
-
}
-
-
/**
-
* 音乐消息对象转换成xml
-
*
-
* @param musicMessage 音乐消息对象
-
* @return xml
-
*/
-
public static String musicMessageToXml(MusicMessage musicMessage) {
-
xstream.alias("xml", musicMessage.getClass());
-
return xstream.toXML(musicMessage);
-
}
-
-
/**
-
* 图文消息对象转换成xml
-
*
-
* @param newsMessage 图文消息对象
-
* @return xml
-
*/
推荐阅读
-
PHPcURL获取微信公众号access_token的实例php实例:这篇文章主要介绍了PHPcURL获取微信公众号access_token的实例,需要的朋友可以参考下1.开发微信 ...
[详细]
蜡笔小新 2024-09-30 13:04:56
-
1、下载官网:https:www.php.netdownloads#cdmydata#wgethttps:www.php.netdistributionsphp ...
[详细]
蜡笔小新 2024-09-30 19:32:33
-
-
01 行业分析本文所研究的细分赛道为:Web3应用层——社交与内容场景——DID/创新场景(以元宇宙3D空间为 ...
[详细]
蜡笔小新 2024-09-29 12:10:23
-
以下将展示微信小程序之表单组件input源码官方组件能力,组件样式仅供参考,开发者可根据自身需求定义组件样式,具体属性参数详见小程序开发文档。功能描述:输入框。该组件是原生组件, ...
[详细]
蜡笔小新 2024-09-28 17:10:30
-
在金融银行业,保护机密信息的安全至关重要。由于财务记录完全通过在线数据库维护,因此实施保护客户、银行和金融机构免受黑客攻击的安全功能比以往任何时候都更加重要。安全套接字层(SSL) ...
[详细]
蜡笔小新 2024-09-30 21:45:53
-
1、跨域的基本概念a、跨域的解释要了解跨域,首先需要知晓浏览器的同源策略,简单的说就是两个请求协议、端口、主机都相同,则两个请求具有相同的 ...
[详细]
蜡笔小新 2024-09-30 19:24:12
-
这是orginally答复Elias的内容:为什么不需要E5风险控制我们一致认为E4和3.x并不是100%兼容的,E4只是提供了一个兼容层用于运行3.x的插件,这其实并不完全符合E4的设计理 ...
[详细]
蜡笔小新 2024-09-30 19:11:14
-
篇首语:本文由编程笔记#小编为大家整理,主要介绍了quarkus实战之一:准备工作相关的知识,希望对你有一定的参考价值。欢迎访问我的GitHub ...
[详细]
蜡笔小新 2024-09-30 16:17:04
-
篇首语:本文由编程笔记#小编为大家整理,主要介绍了Scrum框架的局限性相关的知识,希望对你有一定的参考价值。在很多工作坊的讨论中, ...
[详细]
蜡笔小新 2024-09-30 14:41:28
-
蜡笔小新 2024-09-29 19:47:31
-
四大利器帮你走出IT运维管理的困境2008-10-0717:27:05标签:IT运维管理网络拓扑图 [推送到技术圈]最近给客户做咨询时,跟行业客户谈 ...
[详细]
蜡笔小新 2024-09-29 19:23:54
-
来源| Decrypt编译|黑米 ...
[详细]
蜡笔小新 2024-09-27 18:27:17
-
#regionEnvironmentWindows1021H1Unity2020.3.30f1c1LTSVSCode1.67.2ToneTuneToolkit下载地址 https: ...
[详细]
蜡笔小新 2024-09-27 16:08:24
-
一、出发点平日里,我们看到了很多已经成型的可执行文件,而且经过了一定的封装。因为开源的关系,大多时候可以自己使用eclipse进行编译 ...
[详细]
蜡笔小新 2024-09-26 11:39:45
-
2019独角兽企业重金招聘Python工程师标准点击help--》installnewsoftware--》点击add然后会弹出一个窗口在窗口里面name自己随便填一个Loc ...
[详细]
蜡笔小新 2024-09-25 19:06:38
-
烟台中海地产有限公司往
这个家伙很懒,什么也没留下!