Объясните, что проект - это структура Springboot
1. Файл конфигурации SMS содержит пробег проверки, имя пользователя и пароль
changlan.requesturl = changlan.account = changlan.pswd =
Файл конфигурации
Проверьте конкретное значение для официального веб -сайта, чтобы просмотреть скриншот. Красная коробка была отмечена красной
2. Прочтите класс файлов конфигурации
3. Отправить класс предприятия запроса данных
открытый класс smsvariablerequest {private String account; Private String Password; частная строка MSG; частные строки Params; частная строка SendTime; частный строковый отчет; частная строка Extend; частная строка UID; частная строка MSGID; частная строка Failnum; частная строка успешно; Частный строковый телефон; public smsvariablerequest () {} public smsvariablerequest (string account, String password, String msg, String params) {this.account = account; this.password = пароль; this.msg = msg; this.params = params; } public smsvariaBlereQuest (String Account, String Password, String MSG, String Params, String Report, String Phone) {this.account = account; this.password = пароль; this.msg = msg; this.params = params; this.report = report; this.phone = телефон; } public String getAccount () {return this.account; } public void setAccount (string account) {this.account = account; } public String getPassword () {return this.password; } public void setPassword (String password) {this.password = password; } public String getMsg () {return this.msg; } public void setMsg (String msg) {this.msg = msg; } public String getSendTime () {return this.sendtime; } public void setSendtime (String SendTime) {this.SendTime = sendtime; } public String getReport () {return this.Report; } public void setReport (String Report) {this.Report = report; } public String getExtend () {return this.extend; } public void setExtend (string extend) {this.extend = extend; } public String getUID () {return this.uid; } public void setuid (string uid) {this.uid = uid; } public String getParams () {return this.params; } public void setParams (String params) {this.params = params; } public String getMsgid () {return msgid;} public void setMsgid (string msgid) {this.msgid = msgid;} public String getFailNum () {return failnum;} public void setFailNum (string failnum) {this.failnum = failnum;} public string getCcessnum () {return vecksnum; setSuccessNum (String SuccessNum) {this.Successnum = successNum;} public String getPhone () {return Phone;} public void setphone (String Phone) {this.phone = phone;}}4. Получить класс объектов ответа данных
открытый класс smsvariablerestonse {private String Time; частная строка MSGID; Private String errorrrmsg; частная строка Failnum; частная строка успешно; частный строковый код; public String getTime () {return this.Time; } public void settime (строка времени) {this.Time = time; } public String getMsgid () {return this.msgid; } public void setMsgid (String msgid) {this.msgid = msgid; } public String geterRormsg () {return this.errormsg; } public void seterRorrmsg (string errorrrmsg) {this.errormsg = errormsg; } public String getCode () {return this.code; } public void setCode (String Code) {this.code = code; } public String getFailNum () {return this.failnum; } public void setFailNum (string failnum) {this.failnum = failnum; } public String getSuccessNum () {return this.successnum; } public void setSuccessNum (String SuccessNum) {this.successnum = successnum; } public String toString () {return "smsvarableResponse [time =" + this.time + ", msgid =" + this.msgid + ", errormsg =" + this.errormsg + ", failnum =" + this.failnum + ", successnum =" + this.successnum + ", code =" + this.code = "; }5. Chuanglan SMS
открытый класс chuanglansmsutil {public static String sendsmsbypost (String Path, String postcontent) {url url = null; try {url = new url (path); Httpurlconnection httpurlconnection = (httpurlconnection) url.openconcenection (); httpurlconnection.setrequestmethod ("post"); httpurlconnection.setConnecttimeout (10000); httpurlconnection.setreadtimeout (2000); httpurlconnection.setDoOutput (true); httpurlconnection.setDoinput (true); httpurlconnection.setrequestproperty ("charset", "UTF-8"); httpurlconnection.setRequestProperty ("Content-Type", "Application/json"); httpurlconnection.connect (); OutputStream OS = httpurlConnection.getOutputStream (); OS.Write (postcontent.getBytes ("UTF-8")); os.flush (); StringBuilder SB = new StringBuilder (); int httprspcode = httpurlConnection.getReponseCode (); if (httprspcode == 200) {BufferedReader br = new BufferedReader (new InputStreamReader (httpurlConnection.getInputStream (), "UTF-8")); String line = null; while ((line = br.readline ())! = null) {sb.append (line); } br.close (); вернуть sb.toString (); }} catch (Exception e) {e.printstackTrace (); } return null; }}6. Отправить код для проверки SMS.
@Override public map <string, Object> send (String Content, String mobilEnumber) {string report = "true"; Content = "【】 Ваш код проверки:"+content; Smsvariablerequest smsvariablerequest = new smsvariablerequest (chuanglansmsconstants.getAccount (), changlansmsconstants.getpswd (), содержание, нулевое, отчет, мобильный.); String requestJson = json.tojsonstring (smsvariablerequest); String response = chuanglansmsutil.sendsmsbypost (chuanglansmsconstants.getRequesturl (), requestJson); Smsvariableresponse smsvariablerestonse = (smsvariablerestonse) json.parseobject (ответ, smsvariablerestonse.class); System.out.println («Ответ toString:» + smsvariablerestonse); if (null! = smsvariablerestonse &&! "0" .equals (smsvariablerestonse.getCode ())) {if (log.isInfoEnabled ()) {log.info (smsvaribleresponse); }} return null; }7. Что следует отметить
(1) Обратите внимание на SMS -подпись [xxxx], должна быть подписью, утвержденной Chuanglan SMS. Если это тест, вы можете использовать [253 Cloud Communication] по умолчанию без каких -либо проблем.
(2) Ошибка, возвращаемая SMS Chuanglan, не очень ясна. Не обращайте внимания на ошибку, возвращенную Чуанланом на консоли. Обратите внимание на онлайн -API Chuanglan SMS.
(3) Обратите внимание, что просмотр онлайн -демонстраций не рекомендуется наблюдать за офлайн -демонстрациями. Будут случаи, когда онлайн -демонстрации были обновлены, а в автономных демонстрациях еще не обновляются.
(4) Если вам нужно определить, успешно ли отправлен код проверки, это «0». Equals (smsvariablerestonse.getCode ()) "0" означает, что отправка успешна
Приведенный выше пример объяснения доступа Java к коду проверки SMS 253 - это все контент, которым я делюсь с вами. Я надеюсь, что вы можете дать вам ссылку, и я надеюсь, что вы сможете поддержать Wulin.com больше.