chuanglan 253 SMS 서비스 플랫폼을 기반으로 Java Call SMS 인터페이스 API
package com.bcloud.msg.http; import java.io.bytearrayoutputStream; import java.io.inputstream; import java.net.urldecoder; import org.apache.commons.httpclient.httpclient; import org.apache.commons.httpclient.httpclient org.apache.commons.httpclient.httpstatus; import org.apache.commons.httpclient.namevaluepair; import org.apache.commons.httpclient.namevaluepair; import org.apache.commons.httpclient.uri; 수입 org.apache.commons.httpclient.methods.getMethod; /** * * * @param url 응용 프로그램 주소, http : // ip : port/msg/ * @param 계정 계정 * @param pswd password * @param msg sms content * @param msg sms content * @param needstatus 상태 보고서가 필요한지, 거짓 */공개적 가치 정의를 참조하십시오. BatchSend (문자열 URL, 문자열 계정, String PSWD, String Mobile, String Msg, Boolean Needstatus, String ExtNo) 예외 {httpclient Client = New Httpclient (); getMethod 메서드 = New GetMethod (); try {uri base = new uri (url, false); method.seturi (new uri (base, "httpbatchsendsm", false); Method.setQueryString (새 이름 ValuePair [] {New NameValuePair ( "계정", 계정), New NameValuePair ( "PSWD", PSWD), New NameValuePair ( "Mobile", Mobile), New NameValuePair ( "Needstatus", String.valueof (NewsTatus)), New New valuePair ( "New MSG), New Msg) NameValuePair ( "ExtNo", ExtNo),}); int result = client.executemethod (method); if (result == httpstatus.sc_ok) {inputStream in = method.getResponseBodyAsStream (); BytearRayoutputStream Baos = 새로운 BytearRayoutputStream (); 바이트 [] 버퍼 = 새로운 바이트 [1024]; int len = 0; while ((len = in.read (buffer))! = -1) {baos.write (buffer, 0, len); } return urldecoder.decode (baos.toString (), "utf-8"); } else {wrash new Exception ( "http 오류 상태 :" + method.getStatuscode () + ":" + method.getStatUstext ()); }} 마침내 {method.releaseConnection (); }}}요약
위의 것은 Java가 편집자가 소개 한 Chuanglan 253 SMS 검증 코드를 검색하는 구현 코드입니다. 모든 사람에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 모든 사람에게 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!