이 기사에서는 Java, PHP, C#및 ASP에 의한 SMS의 질량 전송 기능을 구현하는 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 세부 사항은 다음과 같습니다.
먼저 http://www.smschinese.cn/로 이동하여 JAR 패키지를 다운로드하고 사용자를 등록한 다음 API 인터페이스에 전화하여 비밀 키를 얻으십시오.
1. ASP 호출 예제
<%'공통 함수'대상 웹 페이지의 URL을 입력하고 반환 값 gethttppage는 대상 웹 페이지의 HTML 코드 gethttppage (url) dim httpset http = server.createobject ( "msxml2.xmlhttp") http입니다. "get", url, falsehttp .send () http.readystate <> 4 인 경우 http.readystate <> 4 다음에 기능을 종료 한 다음 기능을 종료합니다. ifgethttppage = bytestobstr (http.responsebody, "gb2312") set http = notheif err.number <> 0. bytestobstr (body, cset) dim objstreamset objstream = server.createobject ( "adodb.stream") objstream.type = 1objstream.mode = 3objstream.openobjstream.write bodybjstream.position = 0objstream.type = 2objstream.chars = csetbyteb.redette. objstream.closeset objstream = nothingend function '제출 된 URL을 결합하고 자신의 계정 및 암호 추가 SMS_URL = "http://sms.webchinese.cn/web_api/?uid=account&key=interface key & smsmob = mobile 번호 & smstext = sms 컨텐츠"응답. gethttppage (sms_url)%>를 작성하십시오
2.C# 전화
// 필요한 네임 스페이스는 system.net; system.io를 사용하고; system.text; // 호출 할 때 철자의 URL을 함수로 전달하면됩니다. 반환 값 공개 문자열 gethtmlfromurl (string url) {String strret = null; if (url == null || url.trim (). toString () == "") {return strret;} String targeturl = url. trim (). tostring (); try {httpwebrequest hr = (httpwebrequest) webrequest.create (targeturl); hr.useragent = "mozilla/4.0 (호환 가능한; Windows nt 5.1)"; hr.method = "get" ; hr.timeout = 30 * 60 * 1000; Webresponse hs = hr.getResponse (); 스트림 sr = hs.getResponseStream (); streamreader ser = new StreamReader (sr, encoding.default); strret = ser.readtoend (); } catch (예외) {strret = null;} return strret;}3. 자바 호출
import java.io.unsupportedencodingException; import org.apache.commons.httpclient.header; import org.apache.commons.httpclient.httpclient; import org.apache.commons.httpclient.namevaluepair; import org.apache.commons.httppod .postmethod; public class sendmsg_webchinese {public static void main (string [] args)은 예외 {httpclient client = new httpclient (); 새로운 postmethod ( "http://gbk.sms.webchinese.cn"); .addrequestHeader ( "Content-Type", "Application/x-www-form-urlencoded; charset = gbk"); // transcoding namevaluepair [] data = {new namevaluepair ( "uid", "new site username", New New New Site NameValuePair ( "Key", "Interface Security Password"), New NameValuePair ( "SMSMOB", "휴대 전화 번호"), NEW NAMEVALUEPAIR ( "SMSTEXT", "SMS CONTS"}; executeMethod (post); header [] headers = post.getResponseHeaders (); int statusCode = post.getStatusCode (); system.out.println ( "statusCode :"+statusCode); for (헤더 h : 헤더) {system.out .println (h.tostring ());} string result = new String (post.getResponseBodyAsString (). getBytes ( "gbk"));4. -php
$ url = 'http : //sms.webchinese.cn/web_api/? uid = ac file_get_contents '))) {$ file_contents = file_get_contents ($ url);} else {$ ch = curl_init (); $ timeout = 5; curl_setopt ($ ch, curlopt_url, $ url); curl_setopt ($ ch, curlopt_retransfer, 1); curl_setopt ($ ch, curlopt_connecttimeout, $ timeout); $ file_contents = curl_exec ($ ch); curl_close ($ ch);} return $ file_contents;}5.VB.net
'SMS, NOLIST를 숫자를 받으려면 숫자, 별도의 메모 컨텐츠 70 단어 공개 함수 sendsms (string as string as string으로서의 val nolist, byval memo). .cn/web_api/? uid = account & key = 인터페이스 키 & smsmob = 모바일 번호 & smstext = sms content "new net.webclient () try'dim responseData byte () = dim srcstring as string = webclient.DownloadString (url) 반환 "-444"종료 시도 기능
이 기사가 모든 사람의 Java 프로그래밍에 도움이되기를 바랍니다.