One, SMS platform--inexplicable SMS
Www.duanxin.cm/api.html
The platform can add suffixes and its own definition of the sending content, the user received an example of text messages are as follows:
123456 "Circle Technology"
Second, WebService core code
This is the implementation layer code under the SPRINGMVC framework, and the annotations are all inside.
@Servicepublic class SendPhoneMessageServiceImpl implements SendPhoneMessageService{ @Autowired private MessageMapper Messagemapper; public resultobject sendsms (SMSParams message) { ResultObject Resultobject = new resultobject (); Resultobject.setresultcode (resultcode.failed); //cell phone number validity judgment if (!isMobile ( Message.getphonenumber ())) { Resultobject.setresultmsg (resultmsg.msg_checkphone_failed); return resultobject; } //get the Parameters // account number required to send SMS String smsAccount = ""; // Password string smspwd = ""; // interface address String smsURL = ""; // Send Content String smsContent = ""; SMSInfo messageInfo = Messagemapper.getsmsinfo (); if (MESSAGEINFO&NBsp;! = null) { //Assignment Value smsaccount = messageinfo.getsmsaccount (); smspwd = messageinfo.getsmspwd (); smsurl = messageinfo.getsmsurl (); smsContent = Messageinfo.getsmscontent (); //send content, address is not empty case if (! Smsaccount.isempty () && !smsurl.isEmpty () && smsurl.indexof ("{account}") != -1) { try{ smscontent = urlencoder.encode (smsContent, "UTF-8"); }catch ( Unsupportedencodingexception e) { e.printstacktrace (); } //using the data taken instead of the set smsurl = smsurl.replace ("{account}", smsaccount) . Replace ("{PWD}", smspwd) .replace ("{PHONE}", Message.getphonenumber ()) .replace ("{MESSAGE}", Smscontent); } // Send short Interest System.out.println (Smsurl); &Nbsp; string retvalue = requesturl (SmsURL, "UTF-8"); if (Retvalue.equals (")") { //Send Success resultobject.setresultcode (resultcode.success); resultobject.setresultmsg (resultmsg.msg_send_success); }else{ resultobject.setresultmsg (resultmsg.msg_getsmsinfo_failed); } }else &nbsP; { resultobject.setresultmsg ( resultmsg.msg_getsmsinfo_failed); } return resultObject; } /** * Mobile phone number verification * * @param str * @return verification by returning true */ public static boolean ismobile ( STRING STR) { pattern p = null; Matcher m = null; boolean b = false; // Verify phone number p = pattern.compile ("^[1][3,4,5,7,8][0-9]{9}$"); m = p.matcher (str); b = m.matches (); return b; } /** * Network Requests * * @param String str requested page address * @param String charSet encoding format * @return String page return values */ private string requesturl (String urlstr, string charset) { // URL address of the network URL url = null; // input Stream bufferedreader in = null; stringbuffer sb = new stringbuffer (); try{ url = new url (URLSTR); in = new bufferedreader ( new inputstreamreader ( Url.openstream (), CharSet) ); String str = null; while ((Str = in.readline ()) != null) { sb.append (str); } } catch (Exception ex) { ex.printstacktrace (); system.out.println (Ex.getMessage ()); } finally{ try{ if (in!=null) { in.close (); } }catch (exception Ex) { } } String result = Sb.tostring (); system.out.println (Result); return result; }
Java--webservice Send Verification SMS