|
3 | 3 | import java.util.HashMap;
|
4 | 4 | import java.util.Map;
|
5 | 5 |
|
| 6 | +/** |
| 7 | + * 微信开发所使用到的常量类 |
| 8 | + * |
| 9 | + * @author chanjarster & binarywang |
| 10 | + */ |
6 | 11 | public class WxConsts {
|
7 |
| - |
8 |
| - /////////////////////// |
9 |
| - // 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 |
10 |
| - /////////////////////// |
11 |
| - public static final String XML_MSG_TEXT = "text"; |
12 |
| - public static final String XML_MSG_IMAGE = "image"; |
13 |
| - public static final String XML_MSG_VOICE = "voice"; |
14 |
| - public static final String XML_MSG_SHORTVIDEO = "shortvideo"; |
15 |
| - public static final String XML_MSG_VIDEO = "video"; |
16 |
| - public static final String XML_MSG_NEWS = "news"; |
17 |
| - public static final String XML_MSG_MUSIC = "music"; |
18 |
| - public static final String XML_MSG_LOCATION = "location"; |
19 |
| - public static final String XML_MSG_LINK = "link"; |
20 |
| - public static final String XML_MSG_EVENT = "event"; |
21 |
| - public static final String XML_MSG_DEVICE_TEXT = "device_text"; |
22 |
| - public static final String XML_MSG_DEVICE_EVENT = "device_event"; |
23 |
| - public static final String XML_MSG_DEVICE_STATUS = "device_status"; |
24 |
| - public static final String XML_MSG_HARDWARE = "hardware"; |
25 |
| - public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; |
26 |
| - |
27 |
| - /////////////////////// |
28 |
| - // 主动发送消息(即客服消息)的消息类型 |
29 |
| - /////////////////////// |
30 |
| - public static final String CUSTOM_MSG_TEXT = "text";//文本消息 |
31 |
| - public static final String CUSTOM_MSG_IMAGE = "image";//图片消息 |
32 |
| - public static final String CUSTOM_MSG_VOICE = "voice";//语音消息 |
33 |
| - public static final String CUSTOM_MSG_VIDEO = "video";//视频消息 |
34 |
| - public static final String CUSTOM_MSG_MUSIC = "music";//音乐消息 |
35 |
| - public static final String CUSTOM_MSG_NEWS = "news";//图文消息(点击跳转到外链) |
36 |
| - public static final String CUSTOM_MSG_MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) |
37 |
| - public static final String CUSTOM_MSG_FILE = "file";//发送文件(CP专用) |
38 |
| - public static final String CUSTOM_MSG_TEXTCARD = "textcard";//文本卡片消息(CP专用) |
39 |
| - public static final String CUSTOM_MSG_WXCARD = "wxcard";//卡券消息 |
40 |
| - public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; |
41 |
| - public static final String CUSTOM_MSG_SAFE_NO = "0"; |
42 |
| - public static final String CUSTOM_MSG_SAFE_YES = "1"; |
43 |
| - |
44 |
| - /////////////////////// |
45 |
| - // 群发消息的消息类型 |
46 |
| - /////////////////////// |
47 |
| - public static final String MASS_MSG_NEWS = "mpnews"; |
48 |
| - public static final String MASS_MSG_TEXT = "text"; |
49 |
| - public static final String MASS_MSG_VOICE = "voice"; |
50 |
| - public static final String MASS_MSG_IMAGE = "image"; |
51 |
| - public static final String MASS_MSG_VIDEO = "mpvideo"; |
52 |
| - |
53 |
| - /////////////////////// |
54 |
| - // 群发消息后微信端推送给服务器的反馈消息 |
55 |
| - /////////////////////// |
56 |
| - public static final String MASS_ST_SUCCESS = "send success"; |
57 |
| - public static final String MASS_ST_FAIL = "send fail"; |
58 |
| - public static final String MASS_ST_10001 = "err(10001)"; |
59 |
| - public static final String MASS_ST_20001 = "err(20001)"; |
60 |
| - public static final String MASS_ST_20004 = "err(20004)"; |
61 |
| - public static final String MASS_ST_20002 = "err(20002)"; |
62 |
| - public static final String MASS_ST_20006 = "err(20006)"; |
63 |
| - public static final String MASS_ST_20008 = "err(20008)"; |
64 |
| - public static final String MASS_ST_20013 = "err(20013)"; |
65 |
| - public static final String MASS_ST_22000 = "err(22000)"; |
66 |
| - public static final String MASS_ST_21000 = "err(21000)"; |
67 |
| - |
68 | 12 | /**
|
69 |
| - * 群发反馈消息代码所对应的文字描述 |
| 13 | + * 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 |
70 | 14 | */
|
71 |
| - public static final Map<String, String> MASS_ST_2_DESC = new HashMap<>(); |
72 |
| - |
73 |
| - /////////////////////// |
74 |
| - // 微信端推送过来的事件类型 |
75 |
| - /////////////////////// |
76 |
| - public static final String EVT_SUBSCRIBE = "subscribe"; |
77 |
| - public static final String EVT_UNSUBSCRIBE = "unsubscribe"; |
78 |
| - public static final String EVT_SCAN = "SCAN"; |
79 |
| - public static final String EVT_LOCATION = "LOCATION"; |
80 |
| - public static final String EVT_CLICK = "CLICK"; |
81 |
| - public static final String EVT_VIEW = "VIEW"; |
82 |
| - public static final String EVT_MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; |
83 |
| - public static final String EVT_SCANCODE_PUSH = "scancode_push"; |
84 |
| - public static final String EVT_SCANCODE_WAITMSG = "scancode_waitmsg"; |
85 |
| - public static final String EVT_PIC_SYSPHOTO = "pic_sysphoto"; |
86 |
| - public static final String EVT_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; |
87 |
| - public static final String EVT_PIC_WEIXIN = "pic_weixin"; |
88 |
| - public static final String EVT_LOCATION_SELECT = "location_select"; |
89 |
| - public static final String EVT_TEMPLATESENDJOBFINISH = "TEMPLATESENDJOBFINISH"; |
90 |
| - public static final String EVT_ENTER_AGENT = "enter_agent"; |
91 |
| - |
92 |
| - /////////////////////// |
93 |
| - // 上传多媒体文件的类型 |
94 |
| - /////////////////////// |
95 |
| - public static final String MEDIA_IMAGE = "image"; |
96 |
| - public static final String MEDIA_VOICE = "voice"; |
97 |
| - public static final String MEDIA_VIDEO = "video"; |
98 |
| - public static final String MEDIA_THUMB = "thumb"; |
99 |
| - public static final String MEDIA_FILE = "file"; |
100 |
| - |
| 15 | + public static class XmlMsgType { |
| 16 | + public static final String TEXT = "text"; |
| 17 | + public static final String IMAGE = "image"; |
| 18 | + public static final String VOICE = "voice"; |
| 19 | + public static final String SHORTVIDEO = "shortvideo"; |
| 20 | + public static final String VIDEO = "video"; |
| 21 | + public static final String NEWS = "news"; |
| 22 | + public static final String MUSIC = "music"; |
| 23 | + public static final String LOCATION = "location"; |
| 24 | + public static final String LINK = "link"; |
| 25 | + public static final String EVENT = "event"; |
| 26 | + public static final String DEVICE_TEXT = "device_text"; |
| 27 | + public static final String DEVICE_EVENT = "device_event"; |
| 28 | + public static final String DEVICE_STATUS = "device_status"; |
| 29 | + public static final String HARDWARE = "hardware"; |
| 30 | + public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; |
| 31 | + } |
101 | 32 |
|
102 |
| - /////////////////////// |
103 |
| - // 自定义菜单的按钮类型 |
104 |
| - /////////////////////// |
105 |
| - /** |
106 |
| - * 点击推事件 |
107 |
| - */ |
108 |
| - public static final String BUTTON_CLICK = "click"; |
109 |
| - /** |
110 |
| - * 跳转URL |
111 |
| - */ |
112 |
| - public static final String BUTTON_VIEW = "view"; |
113 |
| - /** |
114 |
| - * 跳转到小程序 |
115 |
| - */ |
116 |
| - public static final String BUTTON_MINIPROGRAM = "miniprogram"; |
117 |
| - /** |
118 |
| - * 扫码推事件 |
119 |
| - */ |
120 |
| - public static final String BUTTON_SCANCODE_PUSH = "scancode_push"; |
121 | 33 | /**
|
122 |
| - * 扫码推事件且弹出“消息接收中”提示框 |
| 34 | + * 主动发送消息(即客服消息)的消息类型 |
123 | 35 | */
|
124 |
| - public static final String BUTTON_SCANCODE_WAITMSG = "scancode_waitmsg"; |
| 36 | + public static class KefuMsgType { |
| 37 | + public static final String TEXT = "text";//文本消息 |
| 38 | + public static final String IMAGE = "image";//图片消息 |
| 39 | + public static final String VOICE = "voice";//语音消息 |
| 40 | + public static final String VIDEO = "video";//视频消息 |
| 41 | + public static final String MUSIC = "music";//音乐消息 |
| 42 | + public static final String NEWS = "news";//图文消息(点击跳转到外链) |
| 43 | + public static final String MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) |
| 44 | + public static final String FILE = "file";//发送文件(CP专用) |
| 45 | + public static final String TEXTCARD = "textcard";//文本卡片消息(CP专用) |
| 46 | + public static final String WXCARD = "wxcard";//卡券消息 |
| 47 | + public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; |
| 48 | + } |
| 49 | + |
125 | 50 | /**
|
126 |
| - * 弹出系统拍照发图 |
| 51 | + * 表示是否是保密消息,0表示否,1表示是,默认0 |
127 | 52 | */
|
128 |
| - public static final String BUTTON_PIC_SYSPHOTO = "pic_sysphoto"; |
| 53 | + public static class KefuMsgSafe { |
| 54 | + public static final String NO = "0"; |
| 55 | + public static final String YES = "1"; |
| 56 | + } |
| 57 | + |
129 | 58 | /**
|
130 |
| - * 弹出拍照或者相册发图 |
| 59 | + * 群发消息的消息类型 |
131 | 60 | */
|
132 |
| - public static final String BUTTON_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; |
| 61 | + public static class MassMsgType { |
| 62 | + public static final String MPNEWS = "mpnews"; |
| 63 | + public static final String TEXT = "text"; |
| 64 | + public static final String VOICE = "voice"; |
| 65 | + public static final String IMAGE = "image"; |
| 66 | + public static final String MPVIDEO = "mpvideo"; |
| 67 | + } |
| 68 | + |
133 | 69 | /**
|
134 |
| - * 弹出微信相册发图器 |
| 70 | + * 群发消息后微信端推送给服务器的反馈消息 |
135 | 71 | */
|
136 |
| - public static final String BUTTON_PIC_WEIXIN = "pic_weixin"; |
| 72 | + public static class MassMsgStatus { |
| 73 | + public static final String SEND_SUCCESS = "send success"; |
| 74 | + public static final String SEND_FAIL = "send fail"; |
| 75 | + public static final String ERR_10001 = "err(10001)"; |
| 76 | + public static final String ERR_20001 = "err(20001)"; |
| 77 | + public static final String ERR_20004 = "err(20004)"; |
| 78 | + public static final String ERR_20002 = "err(20002)"; |
| 79 | + public static final String ERR_20006 = "err(20006)"; |
| 80 | + public static final String ERR_20008 = "err(20008)"; |
| 81 | + public static final String ERR_20013 = "err(20013)"; |
| 82 | + public static final String ERR_22000 = "err(22000)"; |
| 83 | + public static final String ERR_21000 = "err(21000)"; |
| 84 | + |
| 85 | + /** |
| 86 | + * 群发反馈消息代码所对应的文字描述 |
| 87 | + */ |
| 88 | + public static final Map<String, String> STATUS_DESC = new HashMap<>(); |
| 89 | + |
| 90 | + static { |
| 91 | + STATUS_DESC.put(SEND_SUCCESS, "发送成功"); |
| 92 | + STATUS_DESC.put(SEND_FAIL, "发送失败"); |
| 93 | + STATUS_DESC.put(ERR_10001, "涉嫌广告"); |
| 94 | + STATUS_DESC.put(ERR_20001, "涉嫌政治"); |
| 95 | + STATUS_DESC.put(ERR_20004, "涉嫌社会"); |
| 96 | + STATUS_DESC.put(ERR_20002, "涉嫌色情"); |
| 97 | + STATUS_DESC.put(ERR_20006, "涉嫌违法犯罪"); |
| 98 | + STATUS_DESC.put(ERR_20008, "涉嫌欺诈"); |
| 99 | + STATUS_DESC.put(ERR_20013, "涉嫌版权"); |
| 100 | + STATUS_DESC.put(ERR_22000, "涉嫌互推_互相宣传"); |
| 101 | + STATUS_DESC.put(ERR_21000, "涉嫌其他"); |
| 102 | + } |
| 103 | + } |
| 104 | + |
137 | 105 | /**
|
138 |
| - * 弹出地理位置选择器 |
| 106 | + * 微信端推送过来的事件类型 |
139 | 107 | */
|
140 |
| - public static final String BUTTON_LOCATION_SELECT = "location_select"; |
| 108 | + public static class EventType { |
| 109 | + public static final String SUBSCRIBE = "subscribe"; |
| 110 | + public static final String UNSUBSCRIBE = "unsubscribe"; |
| 111 | + public static final String SCAN = "SCAN"; |
| 112 | + public static final String LOCATION = "LOCATION"; |
| 113 | + public static final String CLICK = "CLICK"; |
| 114 | + public static final String VIEW = "VIEW"; |
| 115 | + public static final String MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; |
| 116 | + public static final String SCANCODE_PUSH = "scancode_push"; |
| 117 | + public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; |
| 118 | + public static final String PIC_SYSPHOTO = "pic_sysphoto"; |
| 119 | + public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; |
| 120 | + public static final String PIC_WEIXIN = "pic_weixin"; |
| 121 | + public static final String LOCATION_SELECT = "location_select"; |
| 122 | + public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH"; |
| 123 | + public static final String ENTER_AGENT = "enter_agent"; |
| 124 | + } |
| 125 | + |
141 | 126 | /**
|
142 |
| - * 下发消息(除文本消息) |
| 127 | + * 上传多媒体(临时素材)文件的类型 |
143 | 128 | */
|
144 |
| - public static final String BUTTON_MEDIA_ID = "media_id"; |
| 129 | + public static class MediaFileType { |
| 130 | + public static final String IMAGE = "image"; |
| 131 | + public static final String VOICE = "voice"; |
| 132 | + public static final String VIDEO = "video"; |
| 133 | + public static final String THUMB = "thumb"; |
| 134 | + public static final String FILE = "file"; |
| 135 | + } |
| 136 | + |
145 | 137 | /**
|
146 |
| - * 跳转图文消息URL |
| 138 | + * 自定义菜单的按钮类型 |
147 | 139 | */
|
148 |
| - public static final String BUTTON_VIEW_LIMITED = "view_limited"; |
| 140 | + public static class MenuButtonType { |
| 141 | + /** |
| 142 | + * 点击推事件 |
| 143 | + */ |
| 144 | + public static final String CLICK = "click"; |
| 145 | + /** |
| 146 | + * 跳转URL |
| 147 | + */ |
| 148 | + public static final String VIEW = "view"; |
| 149 | + /** |
| 150 | + * 跳转到小程序 |
| 151 | + */ |
| 152 | + public static final String MINIPROGRAM = "miniprogram"; |
| 153 | + /** |
| 154 | + * 扫码推事件 |
| 155 | + */ |
| 156 | + public static final String SCANCODE_PUSH = "scancode_push"; |
| 157 | + /** |
| 158 | + * 扫码推事件且弹出“消息接收中”提示框 |
| 159 | + */ |
| 160 | + public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; |
| 161 | + /** |
| 162 | + * 弹出系统拍照发图 |
| 163 | + */ |
| 164 | + public static final String PIC_SYSPHOTO = "pic_sysphoto"; |
| 165 | + /** |
| 166 | + * 弹出拍照或者相册发图 |
| 167 | + */ |
| 168 | + public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; |
| 169 | + /** |
| 170 | + * 弹出微信相册发图器 |
| 171 | + */ |
| 172 | + public static final String PIC_WEIXIN = "pic_weixin"; |
| 173 | + /** |
| 174 | + * 弹出地理位置选择器 |
| 175 | + */ |
| 176 | + public static final String LOCATION_SELECT = "location_select"; |
| 177 | + /** |
| 178 | + * 下发消息(除文本消息) |
| 179 | + */ |
| 180 | + public static final String MEDIA_ID = "media_id"; |
| 181 | + /** |
| 182 | + * 跳转图文消息URL |
| 183 | + */ |
| 184 | + public static final String VIEW_LIMITED = "view_limited"; |
| 185 | + } |
149 | 186 |
|
150 | 187 | /**
|
151 |
| - * 不弹出授权页面,直接跳转,只能获取用户openid |
| 188 | + * oauth2网页授权的scope |
152 | 189 | */
|
153 |
| - public static final String OAUTH2_SCOPE_BASE = "snsapi_base"; |
| 190 | + public static class OAuth2Scope { |
| 191 | + /** |
| 192 | + * 不弹出授权页面,直接跳转,只能获取用户openid |
| 193 | + */ |
| 194 | + public static final String SNSAPI_BASE = "snsapi_base"; |
| 195 | + /** |
| 196 | + * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 |
| 197 | + */ |
| 198 | + public static final String SNSAPI_USERINFO = "snsapi_userinfo"; |
| 199 | + } |
154 | 200 |
|
155 |
| - /////////////////////// |
156 |
| - // oauth2网页授权的scope |
157 |
| - /////////////////////// |
158 | 201 | /**
|
159 |
| - * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 |
| 202 | + * 网页应用登录授权作用域 |
160 | 203 | */
|
161 |
| - public static final String OAUTH2_SCOPE_USER_INFO = "snsapi_userinfo"; |
| 204 | + public static class QrConnectScope { |
| 205 | + public static final String SNSAPI_LOGIN = "snsapi_login"; |
| 206 | + } |
162 | 207 |
|
163 | 208 | /**
|
164 |
| - * 网页应用登录授权作用域 snsapi_login |
| 209 | + * 永久素材类型 |
165 | 210 | */
|
166 |
| - public static final String QRCONNECT_SCOPE_SNSAPI_LOGIN = "snsapi_login"; |
167 |
| - |
168 |
| - /////////////////////// |
169 |
| - // 永久素材类型 |
170 |
| - /////////////////////// |
171 |
| - public static final String MATERIAL_NEWS = "news"; |
172 |
| - public static final String MATERIAL_VOICE = "voice"; |
173 |
| - public static final String MATERIAL_IMAGE = "image"; |
174 |
| - public static final String MATERIAL_VIDEO = "video"; |
175 |
| - |
176 |
| - static { |
177 |
| - MASS_ST_2_DESC.put(MASS_ST_SUCCESS, "发送成功"); |
178 |
| - MASS_ST_2_DESC.put(MASS_ST_FAIL, "发送失败"); |
179 |
| - MASS_ST_2_DESC.put(MASS_ST_10001, "涉嫌广告"); |
180 |
| - MASS_ST_2_DESC.put(MASS_ST_20001, "涉嫌政治"); |
181 |
| - MASS_ST_2_DESC.put(MASS_ST_20004, "涉嫌社会"); |
182 |
| - MASS_ST_2_DESC.put(MASS_ST_20002, "涉嫌色情"); |
183 |
| - MASS_ST_2_DESC.put(MASS_ST_20006, "涉嫌违法犯罪"); |
184 |
| - MASS_ST_2_DESC.put(MASS_ST_20008, "涉嫌欺诈"); |
185 |
| - MASS_ST_2_DESC.put(MASS_ST_20013, "涉嫌版权"); |
186 |
| - MASS_ST_2_DESC.put(MASS_ST_22000, "涉嫌互推_互相宣传"); |
187 |
| - MASS_ST_2_DESC.put(MASS_ST_21000, "涉嫌其他"); |
| 211 | + public static class MaterialType { |
| 212 | + public static final String NEWS = "news"; |
| 213 | + public static final String VOICE = "voice"; |
| 214 | + public static final String IMAGE = "image"; |
| 215 | + public static final String VIDEO = "video"; |
188 | 216 | }
|
189 | 217 | }
|
0 commit comments