1 package com.foxinmy.weixin4j.response;
2
3
4
5
6
7
8
9
10
11
12 public class MusicResponse implements WeixinResponse {
13
14
15
16
17 private String thumbMediaId;
18
19
20
21 private String title;
22
23
24
25 private String desc;
26
27
28
29 private String musicUrl;
30
31
32
33 private String hqMusicUrl;
34
35 public MusicResponse(String thumbMediaId) {
36 this.thumbMediaId = thumbMediaId;
37 }
38
39 @Override
40 public String toContent() {
41 StringBuilder content = new StringBuilder();
42 content.append("<Music>");
43 content.append(String.format(
44 "<ThumbMediaId><![CDATA[%s]]></ThumbMediaId>", thumbMediaId));
45 content.append(String.format("<Title><![CDATA[%s]]></Title>",
46 title != null ? title : ""));
47 content.append(String.format(
48 "<Description><![CDATA[%s]]></Description>",
49 desc != null ? desc : ""));
50 content.append(String.format("<MusicUrl><![CDATA[%s]]></MusicUrl>",
51 musicUrl != null ? musicUrl : ""));
52 content.append(String.format("<HQMusicUrl><![CDATA[%s]]></HQMusicUrl>",
53 hqMusicUrl != null ? hqMusicUrl : ""));
54 content.append("</Music>");
55 return content.toString();
56 }
57
58 public String getThumbMediaId() {
59 return thumbMediaId;
60 }
61
62 public String getMusicUrl() {
63 return musicUrl;
64 }
65
66 public void setMusicUrl(String musicUrl) {
67 this.musicUrl = musicUrl;
68 }
69
70 public String getHqMusicUrl() {
71 return hqMusicUrl;
72 }
73
74 public void setHqMusicUrl(String hqMusicUrl) {
75 this.hqMusicUrl = hqMusicUrl;
76 }
77
78 public String getTitle() {
79 return title;
80 }
81
82 public void setTitle(String title) {
83 this.title = title;
84 }
85
86 public String getDesc() {
87 return desc;
88 }
89
90 public void setDesc(String desc) {
91 this.desc = desc;
92 }
93
94 @Override
95 public String getMsgType() {
96 return "music";
97 }
98 }