├── .classpath
├── .idea
├── misc.xml
└── modules.xml
├── .project
├── .settings
├── .jsdtscope
├── org.eclipse.core.resources.prefs
├── org.eclipse.jdt.core.prefs
├── org.eclipse.wst.common.component
├── org.eclipse.wst.common.project.facet.core.xml
├── org.eclipse.wst.jsdt.ui.superType.container
└── org.eclipse.wst.jsdt.ui.superType.name
├── README.md
├── WebContent
├── META-INF
│ └── MANIFEST.MF
└── WEB-INF
│ ├── lib
│ ├── annotations-api.jar
│ ├── catalina-ant.jar
│ ├── catalina-ha.jar
│ ├── catalina-tribes.jar
│ ├── catalina.jar
│ ├── commons-codec-1.9.jar
│ ├── ecj-4.4.jar
│ ├── el-api.jar
│ ├── gson-2.0.jar
│ ├── jasper-el.jar
│ ├── jasper.jar
│ ├── jsp-api.jar
│ ├── servlet-api.jar
│ ├── tomcat-api.jar
│ ├── tomcat-coyote.jar
│ ├── tomcat-dbcp.jar
│ ├── tomcat-i18n-es.jar
│ ├── tomcat-i18n-fr.jar
│ ├── tomcat-i18n-ja.jar
│ ├── tomcat-jdbc.jar
│ ├── tomcat-util.jar
│ ├── tomcat7-websocket.jar
│ └── websocket-api.jar
│ └── web.xml
├── javaHttpApiDemo.iml
└── src
└── com
└── miaodiyun
├── httpApiDemo
├── AccountInfo.java
├── AffMarkSMS.java
├── IndustrySMS.java
├── Test.java
├── VoiceCode.java
└── common
│ ├── Config.java
│ └── HttpUtil.java
└── huiDiao
├── MoNotice.java
├── ReceNotice.java
├── RespCode.java
├── VoiceBack.java
└── entity
├── MoNoticeReq.java
├── MoNoticeResp.java
├── ReceNoticeReq.java
├── ReceNoticeResp.java
├── VoiceBackRep.java
└── VoiceBackResp.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | javaHttpApiDemo
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.jsdt.core.javascriptValidator
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.common.project.facet.core.builder
20 |
21 |
22 |
23 |
24 | org.eclipse.wst.validation.validationbuilder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.jem.workbench.JavaEMFNature
31 | org.eclipse.wst.common.modulecore.ModuleCoreNature
32 | org.eclipse.wst.common.project.facet.core.nature
33 | org.eclipse.jdt.core.javanature
34 | org.eclipse.wst.jsdt.core.jsNature
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.settings/.jsdtscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6 | org.eclipse.jdt.core.compiler.compliance=1.7
7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.source=1.7
13 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.jsdt.ui.superType.container:
--------------------------------------------------------------------------------
1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.jsdt.ui.superType.name:
--------------------------------------------------------------------------------
1 | Window
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SMS-verification
2 |
3 | 手机短信验证现在在各种系统可以说都是用的非常普遍的,这个可能是方便和安全性的考虑,所以才广泛的使用,这篇文章就以一个短信接口的实例,来讲解一下怎么使用短信接口。
4 |
5 | ### 一、前期工作
6 | 首先,我们需要选定一家短信接口的公司,然后去注册和获取一系列的ID等,然后就可以正式的创建我们的短信业务了。下面以某个短信接口为例讲解。
7 |
8 | ## 1.1、注册
9 | http://www.miaodiyun.com/index.html(对于用哪个平台的看个人,这个只是实例)
10 |
11 | ## 1.2、获取到ACCOUNT SID和AUTH TOKEN
12 | 
13 |
14 | ## 1.3、创建短信模板
15 | 
16 |
17 | 如上图,点击**配置管理**,然后进入到**短信模板**,再点击**新建模板**,创建好你的**短信模板**。
18 |
19 | 下面给出我的模板作为参考。
20 | 
21 |
22 | **注意:**上面创建的**短信模板**的信息,需要在代码中用到,并且一定需要保持一致,否则,会出现异常。
23 |
24 | 例如,上面的**短信模板**的信息应为:“【欧阳科技】登录验证码:{1},如非本人操作,请忽略此短信。”,`{1}`为占位符,是你的短信验证码。
25 |
26 | 好了,有了这些准备之后,就可以开始发短信了。
27 |
28 | ### 二、具体代码
29 | **config.java:**
30 | 这个类主要是一些常亮参数的配置信息。
31 |
32 | 这里我们需要修改我们注册时获取到的`ACCOUNT SID`和`AUTH TOKEN`。
33 | ```
34 |
35 | /**
36 | * 系统常量
37 | */
38 | public class Config
39 | {
40 | /**
41 | * url前半部分
42 | */
43 | public static final String BASE_URL = "https://api.miaodiyun.com/20150822";
44 |
45 | /**
46 | * 开发者注册后系统自动生成的账号,可在官网登录后查看
47 | */
48 | public static final String ACCOUNT_SID = "aac6e373c7534007bf47648ba34ba2f1";
49 |
50 | /**
51 | * 开发者注册后系统自动生成的TOKEN,可在官网登录后查看
52 | */
53 | public static final String AUTH_TOKEN = "47605360a97a4f81bcd576e8e0645edf";
54 |
55 | /**
56 | * 响应数据类型, JSON或XML
57 | */
58 | public static final String RESP_DATA_TYPE = "json";
59 | }
60 | ```
61 |
62 | **HttpUtil.java(http请求工具):**
63 |
64 | ```
65 |
66 | import java.io.BufferedReader;
67 | import java.io.IOException;
68 | import java.io.InputStreamReader;
69 | import java.io.OutputStreamWriter;
70 | import java.net.URL;
71 | import java.net.URLConnection;
72 | import java.text.SimpleDateFormat;
73 | import java.util.Date;
74 |
75 | import org.apache.commons.codec.digest.DigestUtils;
76 |
77 | /**
78 | * http请求工具
79 | */
80 | public class HttpUtil
81 | {
82 | /**
83 | * 构造通用参数timestamp、sig和respDataType
84 | *
85 | * @return
86 | */
87 | public static String createCommonParam()
88 | {
89 | // 时间戳
90 | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
91 | String timestamp = sdf.format(new Date());
92 |
93 | // 签名
94 | String sig = DigestUtils.md5Hex(Config.ACCOUNT_SID + Config.AUTH_TOKEN + timestamp);
95 |
96 | return "×tamp=" + timestamp + "&sig=" + sig + "&respDataType=" + Config.RESP_DATA_TYPE;
97 | }
98 |
99 | /**
100 | * post请求
101 | *
102 | * @param url
103 | * 功能和操作
104 | * @param body
105 | * 要post的数据
106 | * @return
107 | * @throws IOException
108 | */
109 | public static String post(String url, String body)
110 | {
111 | System.out.println("url:" + System.lineSeparator() + url);
112 | System.out.println("body:" + System.lineSeparator() + body);
113 |
114 | String result = "";
115 | try
116 | {
117 | OutputStreamWriter out = null;
118 | BufferedReader in = null;
119 | URL realUrl = new URL(url);
120 | URLConnection conn = realUrl.openConnection();
121 |
122 | // 设置连接参数
123 | conn.setDoOutput(true);
124 | conn.setDoInput(true);
125 | conn.setConnectTimeout(5000);
126 | conn.setReadTimeout(20000);
127 | conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
128 | // 提交数据
129 | out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
130 | out.write(body);
131 | out.flush();
132 |
133 | // 读取返回数据
134 | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
135 | String line = "";
136 | boolean firstLine = true; // 读第一行不加换行符
137 | while ((line = in.readLine()) != null)
138 | {
139 | if (firstLine)
140 | {
141 | firstLine = false;
142 | } else
143 | {
144 | result += System.lineSeparator();
145 | }
146 | result += line;
147 | }
148 | } catch (Exception e)
149 | {
150 | e.printStackTrace();
151 | }
152 | return result;
153 | }
154 |
155 | /**
156 | * 回调测试工具方法
157 | *
158 | * @param url
159 | * @param reqStr
160 | * @return
161 | */
162 | public static String postHuiDiao(String url, String body)
163 | {
164 | String result = "";
165 | try
166 | {
167 | OutputStreamWriter out = null;
168 | BufferedReader in = null;
169 | URL realUrl = new URL(url);
170 | URLConnection conn = realUrl.openConnection();
171 |
172 | // 设置连接参数
173 | conn.setDoOutput(true);
174 | conn.setDoInput(true);
175 | conn.setConnectTimeout(5000);
176 | conn.setReadTimeout(20000);
177 |
178 | // 提交数据
179 | out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
180 | out.write(body);
181 | out.flush();
182 |
183 | // 读取返回数据
184 | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
185 | String line = "";
186 | boolean firstLine = true; // 读第一行不加换行符
187 | while ((line = in.readLine()) != null)
188 | {
189 | if (firstLine)
190 | {
191 | firstLine = false;
192 | } else
193 | {
194 | result += System.lineSeparator();
195 | }
196 | result += line;
197 | }
198 | } catch (Exception e)
199 | {
200 | e.printStackTrace();
201 | }
202 | return result;
203 | }
204 | }
205 | ```
206 |
207 | **验证码通知短信接口:(最重要)**
208 | 这里需要修改我们在注册时获取到的信息。
209 |
210 | - 修改smsContent
211 | 把这个短信的内容修改为你创建的**短信模板**
212 | **注意:**一定要保持一致。
213 | ```
214 | import java.net.URLEncoder;
215 |
216 | import com.miaodiyun.httpApiDemo.common.Config;
217 | import com.miaodiyun.httpApiDemo.common.HttpUtil;
218 |
219 | /**
220 | * 验证码通知短信接口
221 | *
222 | * @ClassName: IndustrySMS
223 | * @Description: 验证码通知短信接口
224 | *
225 | */
226 | public class IndustrySMS
227 | {
228 | private static String operation = "/industrySMS/sendSMS";
229 |
230 | private static String accountSid = Config.ACCOUNT_SID;
231 | private static String to = "13767441759";
232 |
233 | private static String code = smsCode();
234 | // 登录验证码:{1},如非本人操作,请忽略此短信。
235 | private static String smsContent = "【欧阳科技】登录验证码:"+code+",如非本人操作,请忽略此短信。";
236 |
237 | /**
238 | * 验证码通知短信
239 | */
240 | public static void execute()
241 | {
242 | String tmpSmsContent = null;
243 | try{
244 | tmpSmsContent = URLEncoder.encode(smsContent, "UTF-8");
245 | }catch(Exception e){
246 |
247 | }
248 | String url = Config.BASE_URL + operation;
249 | String body = "accountSid=" + accountSid + "&to=" + to + "&smsContent=" + tmpSmsContent
250 | + HttpUtil.createCommonParam();
251 |
252 | // 提交请求
253 | String result = HttpUtil.post(url, body);
254 | System.out.println("result:" + System.lineSeparator() + result);
255 | }
256 |
257 | //创建验证码
258 | public static String smsCode(){
259 | String random=(int)((Math.random()*9+1)*100000)+"";
260 | System.out.println("验证码:"+random);
261 | return random;
262 | }
263 | }
264 |
265 | ```
266 |
267 | 上面这些是主要的类,还有其他的类在文章末尾给出源代码。
268 |
269 | ### 三、手机短信验证测试
270 |
271 | ```
272 |
273 | public class Test
274 | {
275 |
276 | /**
277 | * @param args
278 | */
279 | public static void main(String[] args)
280 | {
281 |
282 | // 验证码通知短信接口
283 | IndustrySMS.execute();
284 |
285 | }
286 |
287 |
288 | }
289 |
290 | ```
291 |
292 | #####源代码下载
293 | https://download.csdn.net/download/sihai12345/10472391
294 |
--------------------------------------------------------------------------------
/WebContent/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/annotations-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/annotations-api.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/catalina-ant.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/catalina-ant.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/catalina-ha.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/catalina-ha.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/catalina-tribes.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/catalina-tribes.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/catalina.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/catalina.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-codec-1.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/commons-codec-1.9.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/ecj-4.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/ecj-4.4.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/el-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/el-api.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/gson-2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/gson-2.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jasper-el.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/jasper-el.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jasper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/jasper.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jsp-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/jsp-api.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/servlet-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/servlet-api.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-api.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-coyote.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-coyote.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-dbcp.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-dbcp.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-i18n-es.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-i18n-es.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-i18n-fr.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-i18n-fr.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-i18n-ja.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-i18n-ja.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-jdbc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-jdbc.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat-util.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat-util.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/tomcat7-websocket.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/tomcat7-websocket.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/websocket-api.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hello-java-maker/SMS-verification/78caef51990f435c6cd735ef7bd49f441e6b6f03/WebContent/WEB-INF/lib/websocket-api.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | javaRestApiDemo
4 |
5 | index.html
6 | index.htm
7 | index.jsp
8 | default.html
9 | default.htm
10 | default.jsp
11 |
12 |
--------------------------------------------------------------------------------
/javaHttpApiDemo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/AccountInfo.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo;
2 |
3 | import com.miaodiyun.httpApiDemo.common.Config;
4 | import com.miaodiyun.httpApiDemo.common.HttpUtil;
5 |
6 | /**
7 | * 获取开发者账号信息接口调用示例
8 | *
9 | * @ClassName: AccountInfo
10 | * @Description: 获取开发者账号信息接口调用示例
11 | *
12 | */
13 | public class AccountInfo
14 | {
15 | private static String operation = "/query/accountInfo";
16 |
17 | private static String accountSid = Config.ACCOUNT_SID;
18 |
19 | /**
20 | * 获取开发者账号信息
21 | */
22 | public static void execute()
23 | {
24 | String url = Config.BASE_URL + operation;
25 | String body = "accountSid=" + accountSid + HttpUtil.createCommonParam();
26 |
27 | // 提交请求
28 | String result = HttpUtil.post(url, body);
29 | System.out.println("result:" + System.lineSeparator() + result);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/AffMarkSMS.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo;
2 |
3 | import java.net.URLEncoder;
4 |
5 | import com.miaodiyun.httpApiDemo.common.Config;
6 | import com.miaodiyun.httpApiDemo.common.HttpUtil;
7 |
8 | /**
9 | * 会员营销短信接口
10 | *
11 | * @ClassName: AffMarkSMS
12 | * @Description: 会员营销短信接口
13 | *
14 | */
15 | public class AffMarkSMS
16 | {
17 | private static String operation = "/affMarkSMS/sendSMS";
18 |
19 | private static String accountSid = Config.ACCOUNT_SID;
20 | private static String to = "1361305****";
21 | private static String smsContent = "【秒嘀科技】您的优惠券就快过期啦!不想白白浪费,就快来使用吧!戳: m.miaodiyun.com 使用!回TD退订。";
22 |
23 | /**
24 | * 会员营销短信
25 | */
26 | public static void execute()
27 | {
28 | String tmpSmsContent = null;
29 | try{
30 | tmpSmsContent = URLEncoder.encode(smsContent, "UTF-8");
31 | }catch(Exception e){
32 |
33 | }
34 | String url = Config.BASE_URL + operation;
35 | String body = "accountSid=" + accountSid + "&to=" + to + "&smsContent=" + tmpSmsContent
36 | + HttpUtil.createCommonParam();
37 |
38 | // 提交请求
39 | String result = HttpUtil.post(url, body);
40 | System.out.println("result:" + System.lineSeparator() + result);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/IndustrySMS.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo;
2 |
3 | import java.net.URLEncoder;
4 |
5 | import com.miaodiyun.httpApiDemo.common.Config;
6 | import com.miaodiyun.httpApiDemo.common.HttpUtil;
7 |
8 | /**
9 | * 验证码通知短信接口
10 | *
11 | * @ClassName: IndustrySMS
12 | * @Description: 验证码通知短信接口
13 | *
14 | */
15 | public class IndustrySMS
16 | {
17 | private static String operation = "/industrySMS/sendSMS";
18 |
19 | private static String accountSid = Config.ACCOUNT_SID;
20 | private static String to = "13767441759";
21 |
22 | private static String code = smsCode();
23 | // 登录验证码:{1},如非本人操作,请忽略此短信。
24 | private static String smsContent = "【欧阳科技】登录验证码:"+code+",如非本人操作,请忽略此短信。";
25 |
26 | /**
27 | * 验证码通知短信
28 | */
29 | public static void execute()
30 | {
31 | String tmpSmsContent = null;
32 | try{
33 | tmpSmsContent = URLEncoder.encode(smsContent, "UTF-8");
34 | }catch(Exception e){
35 |
36 | }
37 | String url = Config.BASE_URL + operation;
38 | String body = "accountSid=" + accountSid + "&to=" + to + "&smsContent=" + tmpSmsContent
39 | + HttpUtil.createCommonParam();
40 |
41 | // 提交请求
42 | String result = HttpUtil.post(url, body);
43 | System.out.println("result:" + System.lineSeparator() + result);
44 | }
45 |
46 | //创建验证码
47 | public static String smsCode(){
48 | String random=(int)((Math.random()*9+1)*100000)+"";
49 | System.out.println("验证码:"+random);
50 | return random;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/Test.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo;
2 |
3 | public class Test
4 | {
5 |
6 | /**
7 | * @param args
8 | */
9 | public static void main(String[] args)
10 | {
11 | // 获取开发者账号信息
12 | // AccountInfo.execute();
13 |
14 | // 验证码通知短信接口
15 | IndustrySMS.execute();
16 | // 会员营销短信接口
17 | // AffMarkSMS.execute();
18 |
19 | // 语音验证码
20 | // VoiceCode.execute();
21 |
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/VoiceCode.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo;
2 |
3 | import com.miaodiyun.httpApiDemo.common.Config;
4 | import com.miaodiyun.httpApiDemo.common.HttpUtil;
5 |
6 | /**
7 | * 语音验证码接口
8 | *
9 | * @ClassName: VoiceCode
10 | * @Description: 语音验证码接口
11 | *
12 | */
13 | public class VoiceCode
14 | {
15 | private static String operation = "/call/voiceCode";
16 |
17 | private static String accountSid = Config.ACCOUNT_SID;
18 | private static String verifyCode = "5678";
19 | private static String called = "1361305****";
20 | private static String callDisplayNumber = "";
21 | private static String playTimes = "2";
22 | private static String respUrl = "";
23 |
24 | /**
25 | * 语音验证码
26 | */
27 | public static void execute()
28 | {
29 | String url = Config.BASE_URL + operation;
30 | String body = "accountSid=" + accountSid + "&verifyCode=" + verifyCode + "&called=" + called
31 | + "&callDisplayNumber=" + callDisplayNumber + "&playTimes=" + playTimes + "&respUrl=" + respUrl
32 | + HttpUtil.createCommonParam();
33 |
34 | // 提交请求
35 | String result = HttpUtil.post(url, body);
36 | System.out.println("result:" + System.lineSeparator() + result);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/common/Config.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo.common;
2 |
3 | /**
4 | * 系统常量
5 | */
6 | public class Config
7 | {
8 | /**
9 | * url前半部分
10 | */
11 | public static final String BASE_URL = "https://api.miaodiyun.com/20150822";
12 |
13 | /**
14 | * 开发者注册后系统自动生成的账号,可在官网登录后查看
15 | */
16 | public static final String ACCOUNT_SID = "aac6e373c7534007bf47648ba34ba2f1";
17 |
18 | /**
19 | * 开发者注册后系统自动生成的TOKEN,可在官网登录后查看
20 | */
21 | public static final String AUTH_TOKEN = "47605360a97a4f81bcd576e8e0645edf";
22 |
23 | /**
24 | * 响应数据类型, JSON或XML
25 | */
26 | public static final String RESP_DATA_TYPE = "json";
27 | }
--------------------------------------------------------------------------------
/src/com/miaodiyun/httpApiDemo/common/HttpUtil.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.httpApiDemo.common;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.io.OutputStreamWriter;
7 | import java.net.URL;
8 | import java.net.URLConnection;
9 | import java.text.SimpleDateFormat;
10 | import java.util.Date;
11 |
12 | import org.apache.commons.codec.digest.DigestUtils;
13 |
14 | /**
15 | * http请求工具
16 | */
17 | public class HttpUtil
18 | {
19 | /**
20 | * 构造通用参数timestamp、sig和respDataType
21 | *
22 | * @return
23 | */
24 | public static String createCommonParam()
25 | {
26 | // 时间戳
27 | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
28 | String timestamp = sdf.format(new Date());
29 |
30 | // 签名
31 | String sig = DigestUtils.md5Hex(Config.ACCOUNT_SID + Config.AUTH_TOKEN + timestamp);
32 |
33 | return "×tamp=" + timestamp + "&sig=" + sig + "&respDataType=" + Config.RESP_DATA_TYPE;
34 | }
35 |
36 | /**
37 | * post请求
38 | *
39 | * @param url
40 | * 功能和操作
41 | * @param body
42 | * 要post的数据
43 | * @return
44 | * @throws IOException
45 | */
46 | public static String post(String url, String body)
47 | {
48 | System.out.println("url:" + System.lineSeparator() + url);
49 | System.out.println("body:" + System.lineSeparator() + body);
50 |
51 | String result = "";
52 | try
53 | {
54 | OutputStreamWriter out = null;
55 | BufferedReader in = null;
56 | URL realUrl = new URL(url);
57 | URLConnection conn = realUrl.openConnection();
58 |
59 | // 设置连接参数
60 | conn.setDoOutput(true);
61 | conn.setDoInput(true);
62 | conn.setConnectTimeout(5000);
63 | conn.setReadTimeout(20000);
64 | conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
65 | // 提交数据
66 | out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
67 | out.write(body);
68 | out.flush();
69 |
70 | // 读取返回数据
71 | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
72 | String line = "";
73 | boolean firstLine = true; // 读第一行不加换行符
74 | while ((line = in.readLine()) != null)
75 | {
76 | if (firstLine)
77 | {
78 | firstLine = false;
79 | } else
80 | {
81 | result += System.lineSeparator();
82 | }
83 | result += line;
84 | }
85 | } catch (Exception e)
86 | {
87 | e.printStackTrace();
88 | }
89 | return result;
90 | }
91 |
92 | /**
93 | * 回调测试工具方法
94 | *
95 | * @param url
96 | * @param reqStr
97 | * @return
98 | */
99 | public static String postHuiDiao(String url, String body)
100 | {
101 | String result = "";
102 | try
103 | {
104 | OutputStreamWriter out = null;
105 | BufferedReader in = null;
106 | URL realUrl = new URL(url);
107 | URLConnection conn = realUrl.openConnection();
108 |
109 | // 设置连接参数
110 | conn.setDoOutput(true);
111 | conn.setDoInput(true);
112 | conn.setConnectTimeout(5000);
113 | conn.setReadTimeout(20000);
114 |
115 | // 提交数据
116 | out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
117 | out.write(body);
118 | out.flush();
119 |
120 | // 读取返回数据
121 | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
122 | String line = "";
123 | boolean firstLine = true; // 读第一行不加换行符
124 | while ((line = in.readLine()) != null)
125 | {
126 | if (firstLine)
127 | {
128 | firstLine = false;
129 | } else
130 | {
131 | result += System.lineSeparator();
132 | }
133 | result += line;
134 | }
135 | } catch (Exception e)
136 | {
137 | e.printStackTrace();
138 | }
139 | return result;
140 | }
141 | }
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/MoNotice.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 |
7 | import javax.servlet.ServletException;
8 | import javax.servlet.annotation.WebServlet;
9 | import javax.servlet.http.HttpServlet;
10 | import javax.servlet.http.HttpServletRequest;
11 | import javax.servlet.http.HttpServletResponse;
12 |
13 | import com.google.gson.Gson;
14 | import com.miaodiyun.huiDiao.entity.MoNoticeReq;
15 | import com.miaodiyun.huiDiao.entity.MoNoticeResp;
16 |
17 | /**
18 | * 上行短信接口
19 | *
20 | * @ClassName: MoNotice
21 | * @Description: 上行短信接口
22 | *
23 | */
24 | @WebServlet("/moNotice")
25 | public class MoNotice extends HttpServlet
26 | {
27 | private static final long serialVersionUID = -2119868200097964820L;
28 |
29 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
30 | {
31 | this.doPost(request, response);
32 | }
33 |
34 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
35 | {
36 | // 获取请求参数
37 | BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
38 | String str = null;
39 | StringBuffer reqBody = new StringBuffer();
40 | while ((str = reader.readLine()) != null)
41 | {
42 | reqBody.append(str);
43 | }
44 | System.out.println("收到请求:" + reqBody);
45 |
46 | // 将数据注入对应的bean
47 | Gson gson = new Gson();
48 | MoNoticeReq moNoticeReq = gson.fromJson(reqBody.toString(), MoNoticeReq.class);
49 |
50 | // TODO 判断签名是否正确
51 |
52 | // TODO 业务处理。开发者根据自己的需求实现
53 |
54 | // 响应
55 | MoNoticeResp moNoticeResp = new MoNoticeResp();
56 | moNoticeResp.setRespCode(RespCode.SUCCESS);
57 | String respStr = gson.toJson(moNoticeResp);
58 | System.out.println("返回的数据:" + respStr);
59 |
60 | response.getWriter().write(respStr);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/ReceNotice.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 |
7 | import javax.servlet.ServletException;
8 | import javax.servlet.annotation.WebServlet;
9 | import javax.servlet.http.HttpServlet;
10 | import javax.servlet.http.HttpServletRequest;
11 | import javax.servlet.http.HttpServletResponse;
12 |
13 | import com.google.gson.Gson;
14 | import com.miaodiyun.huiDiao.entity.ReceNoticeReq;
15 | import com.miaodiyun.huiDiao.entity.ReceNoticeResp;
16 |
17 | /**
18 | * 短信回执推送
19 | *
20 | * @ClassName: ReceNotice
21 | * @Description: 短信回执推送
22 | *
23 | */
24 | @WebServlet("/receNotice")
25 | public class ReceNotice extends HttpServlet
26 | {
27 |
28 | private static final long serialVersionUID = -2119868200097964820L;
29 |
30 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
31 | {
32 | this.doPost(request, response);
33 | }
34 |
35 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
36 | {
37 | // 获取请求参数
38 | BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
39 | String str = null;
40 | StringBuffer reqBody = new StringBuffer();
41 | while ((str = reader.readLine()) != null)
42 | {
43 | reqBody.append(str);
44 | }
45 | System.out.println("收到请求:" + reqBody);
46 |
47 | // 将数据注入对应的bean
48 | Gson gson = new Gson();
49 | ReceNoticeReq receNoticeReq = gson.fromJson(reqBody.toString(), ReceNoticeReq.class);
50 |
51 | // TODO 业务处理。开发者根据自己的需求实现
52 |
53 | // 响应
54 | ReceNoticeResp receNoticeResp = new ReceNoticeResp();
55 | receNoticeResp.setRespCode(RespCode.SUCCESS);
56 | String respStr = gson.toJson(receNoticeResp);
57 | System.out.println("返回的数据:" + respStr);
58 |
59 | response.getWriter().write(respStr);
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/RespCode.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao;
2 |
3 | /**
4 | * 响应码常量
5 | *
6 | */
7 | public class RespCode
8 | {
9 | /**
10 | * 成功
11 | */
12 | public static final String SUCCESS = "00000";
13 |
14 | /**
15 | * sign错误
16 | */
17 | public static final String SIGN_ERROR = "00006";
18 | }
19 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/VoiceBack.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 |
7 | import javax.servlet.ServletException;
8 | import javax.servlet.annotation.WebServlet;
9 | import javax.servlet.http.HttpServlet;
10 | import javax.servlet.http.HttpServletRequest;
11 | import javax.servlet.http.HttpServletResponse;
12 |
13 | import org.apache.commons.codec.digest.DigestUtils;
14 |
15 | import com.google.gson.Gson;
16 | import com.google.gson.GsonBuilder;
17 | import com.miaodiyun.httpApiDemo.common.Config;
18 | import com.miaodiyun.huiDiao.entity.VoiceBackRep;
19 | import com.miaodiyun.huiDiao.entity.VoiceBackResp;
20 |
21 | /**
22 | * 语音验证码状态通知接口
23 | *
24 | * @ClassName: VoiceBack
25 | * @Description: 语音验证码状态通知接口
26 | *
27 | */
28 | @WebServlet("/voiceBack")
29 | public class VoiceBack extends HttpServlet
30 | {
31 |
32 | private static final long serialVersionUID = -2119868200097964820L;
33 |
34 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
35 | {
36 | this.doPost(request, response);
37 | }
38 |
39 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
40 | {
41 | // 获取请求参数
42 | BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
43 | String str = null;
44 | StringBuffer reqBody = new StringBuffer();
45 | while ((str = reader.readLine()) != null)
46 | {
47 | reqBody.append(str);
48 | }
49 | System.out.println("收到请求:" + reqBody);
50 |
51 | // 将数据注入对应的bean
52 | Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
53 | VoiceBackRep voiceCallback = gson.fromJson(reqBody.toString(), VoiceBackRep.class);
54 |
55 | // 判断签名是否正确
56 | String sig = DigestUtils.md5Hex(Config.ACCOUNT_SID + Config.AUTH_TOKEN + voiceCallback.getTimestamp());
57 | if (sig.equals(voiceCallback.getSig()))
58 | {
59 | System.out.println("签名正确。");
60 | } else
61 | {
62 | System.out.println("签名错误。");
63 | VoiceBackResp voiceCallbackResp = new VoiceBackResp();
64 | voiceCallbackResp.setRespCode(RespCode.SIGN_ERROR);
65 | String respStr = gson.toJson(voiceCallbackResp);
66 | System.out.println("返回的数据:" + respStr);
67 | response.getWriter().write(respStr);
68 | return;
69 | }
70 |
71 | // TODO 通过callId判断是否重复通知
72 |
73 | // TODO 业务处理。开发者根据自己的需求实现
74 |
75 | // 响应
76 | VoiceBackResp voiceCallbackResp = new VoiceBackResp();
77 | voiceCallbackResp.setRespCode(RespCode.SUCCESS);
78 | String respStr = gson.toJson(voiceCallbackResp);
79 | System.out.println("返回的数据:" + respStr);
80 |
81 | response.getWriter().write(respStr);
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/entity/MoNoticeReq.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao.entity;
2 |
3 | public class MoNoticeReq {
4 | private String MOPort;
5 | private String phone;
6 | private String content;
7 | private String MOTime;
8 | private String timestamp;
9 | private String sig;
10 |
11 | public String getMOPort() {
12 | return MOPort;
13 | }
14 |
15 | public void setMOPort(String MOPort) {
16 | this.MOPort = MOPort;
17 | }
18 |
19 | public String getPhone() {
20 | return phone;
21 | }
22 |
23 | public void setPhone(String phone) {
24 | this.phone = phone;
25 | }
26 |
27 | public String getContent() {
28 | return content;
29 | }
30 |
31 | public void setContent(String content) {
32 | this.content = content;
33 | }
34 |
35 | public String getMOTime() {
36 | return MOTime;
37 | }
38 |
39 | public void setMOTime(String MOTime) {
40 | this.MOTime = MOTime;
41 | }
42 |
43 | public String getTimestamp() {
44 | return timestamp;
45 | }
46 |
47 | public void setTimestamp(String timestamp) {
48 | this.timestamp = timestamp;
49 | }
50 |
51 | public String getSig() {
52 | return sig;
53 | }
54 |
55 | public void setSig(String sig) {
56 | this.sig = sig;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/entity/MoNoticeResp.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao.entity;
2 |
3 | public class MoNoticeResp
4 | {
5 | private String respCode;
6 |
7 | public String getRespCode()
8 | {
9 | return respCode;
10 | }
11 |
12 | public void setRespCode(String respCode)
13 | {
14 | this.respCode = respCode;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/entity/ReceNoticeReq.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao.entity;
2 |
3 | public class ReceNoticeReq
4 | {
5 | private String smsId;
6 | private String phone;
7 | private String status;
8 | private String respMessage;
9 | private String receiveTime;
10 | private String chargingNum;
11 |
12 | public String getSmsId()
13 | {
14 | return smsId;
15 | }
16 |
17 | public void setSmsId(String smsId)
18 | {
19 | this.smsId = smsId;
20 | }
21 |
22 | public String getPhone()
23 | {
24 | return phone;
25 | }
26 |
27 | public void setPhone(String phone)
28 | {
29 | this.phone = phone;
30 | }
31 |
32 | public String getStatus()
33 | {
34 | return status;
35 | }
36 |
37 | public void setStatus(String status)
38 | {
39 | this.status = status;
40 | }
41 |
42 | public String getRespMessage()
43 | {
44 | return respMessage;
45 | }
46 |
47 | public void setRespMessage(String respMessage)
48 | {
49 | this.respMessage = respMessage;
50 | }
51 |
52 | public String getReceiveTime()
53 | {
54 | return receiveTime;
55 | }
56 |
57 | public void setReceiveTime(String receiveTime)
58 | {
59 | this.receiveTime = receiveTime;
60 | }
61 |
62 | public String getChargingNum()
63 | {
64 | return chargingNum;
65 | }
66 |
67 | public void setChargingNum(String chargingNum)
68 | {
69 | this.chargingNum = chargingNum;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/entity/ReceNoticeResp.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao.entity;
2 |
3 | public class ReceNoticeResp
4 | {
5 | private String respCode;
6 |
7 | public String getRespCode()
8 | {
9 | return respCode;
10 | }
11 |
12 | public void setRespCode(String respCode)
13 | {
14 | this.respCode = respCode;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/entity/VoiceBackRep.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao.entity;
2 |
3 | public class VoiceBackRep
4 | {
5 |
6 | private String callId;// 对应接口返回callSid参数,一路呼叫的唯一标示 32位字符串
7 | private String called; // 外呼号码
8 | private String state;// 通话状态 0正常通话 1被叫通话未应答 2外呼失败
9 | private String callTime;// 通话时长
10 | private String DTMFaction;// 用户按键DTMF信息 DTMF验证码内容,为数字长度4-8位
11 | private String timestamp;
12 | private String sig;
13 |
14 | public String getCallTime()
15 | {
16 | return callTime;
17 | }
18 |
19 | public void setCallTime(String callTime)
20 | {
21 | this.callTime = callTime;
22 | }
23 |
24 | public String getCallId()
25 | {
26 | return callId;
27 | }
28 |
29 | public void setCallId(String callId)
30 | {
31 | this.callId = callId;
32 | }
33 |
34 | public String getCalled()
35 | {
36 | return called;
37 | }
38 |
39 | public void setCalled(String called)
40 | {
41 | this.called = called;
42 | }
43 |
44 | public String getState()
45 | {
46 | return state;
47 | }
48 |
49 | public void setState(String state)
50 | {
51 | this.state = state;
52 | }
53 |
54 | public String getDTMFaction()
55 | {
56 | return DTMFaction;
57 | }
58 |
59 | public void setDTMFaction(String dTMFaction)
60 | {
61 | DTMFaction = dTMFaction;
62 | }
63 |
64 | public String getTimestamp()
65 | {
66 | return timestamp;
67 | }
68 |
69 | public void setTimestamp(String timestamp)
70 | {
71 | this.timestamp = timestamp;
72 | }
73 |
74 | public String getSig()
75 | {
76 | return sig;
77 | }
78 |
79 | public void setSig(String sig)
80 | {
81 | this.sig = sig;
82 | }
83 |
84 | @Override
85 | public String toString()
86 | {
87 | return "VoiceBackRep [callId=" + callId + ", called=" + called + ", state=" + state + ", callTime=" + callTime
88 | + ", DTMFaction=" + DTMFaction + ", timestamp=" + timestamp + ", sig=" + sig + "]";
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/com/miaodiyun/huiDiao/entity/VoiceBackResp.java:
--------------------------------------------------------------------------------
1 | package com.miaodiyun.huiDiao.entity;
2 |
3 | public class VoiceBackResp
4 | {
5 | private String respCode;
6 |
7 | public String getRespCode()
8 | {
9 | return respCode;
10 | }
11 |
12 | public void setRespCode(String respCode)
13 | {
14 | this.respCode = respCode;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------