Este artículo describe los métodos para implementar la función de envío de masa de SMS por Java, PHP, C#y ASP. Compártelo para su referencia. Los detalles son los siguientes:
Primero, vaya a http://www.smschinese.cn/ para descargar el paquete jar y registre al usuario, luego llame a la interfaz API para obtener la clave secreta
1. Ejemplo de llamada ASP
<%'Función común' Ingrese la URL de la página web de destino, y el valor de retorno gethttppage es el código HTML de la función de la página web de destino gethttppage (url) dim httpset http = server.createObject ("msxml2.xmlhttp") http. Abra "Get", URL, falsehttp .send () si http.readyState <> 4 entonces salga de funcionamiento ifgethttppage = bytestobstr (http.responseBody, "gb2312") establecer http = notheif err.number <> 0 luego err.lear Funcionfunción final BytestObstr (Body, cSet) dim objStreamset objstream = server.CreateObject ("ADODB.Stream") objStream.Type = 1ObjStream.Mode = 3OBJSTREAM.OPENOBJSTREAM. objstream.closseSet objstream = Nothing Function 'Combine la URL enviada y agregue su propia cuenta y contraseña sms_url = "http://sms.webchinese.cn/web_api/?uid=account&key=interface key & smsmob = número de móvil y smstext = contenido de SMS" Respuesta. Escribe gethttppage (sms_url)%>2.c# llamar
// El espacio de nombres requerido es usar System.net; usando System.io; usando System.Text; // Al llamar, solo necesita pasar la URL deletreada a la función. Simplemente juzgue el valor de retorno public String gethtmlFromUrl (string url) {String strret = null; if (url == null || url.trim (). ToString () == "") {return strret;} String TargetUrl = url. TRIM (). ToString (); intente {httpwebRequest hr = (httpwebRequest) webRequest.create (TargetUrl); hr.useragent = "Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1)"; hr.method = "get" ; hr.timeout = 30 * 60 * 1000; webResponse hs = hr.getResponse (); stream sr = hs.getResponseSteam (); streamReader ser = new StreamReader (sr, coding.default); strret = ser.readtoend (); } capt (excepción ex) {strret = null;} return strret;}3. Llamada de Java
import java.io.unsupportedEncodingException; importar org.apache.commons.httpclient.header; importar org.apache.commons.httpclient.httpclient; importar org.apache.commons.httpclient.nameValuePair; importar org.apache.commons.httpclient.methodsient.methode .PostMethod; public class sendmsg_webchinese {public static void main (string [] args) lanza excepción {httpclient cliente = new httpclient (); postmethod post = new postmethod ("http://gbk.sms.webchinese.cn"); .AdDRequestHeader ("Content-type", "Application/x-www-form-urlencoded; charset = gbk"); // establecer transcodificando nameValuePair [] data = {new nameValuePair ("uid", "este sitio de usuario", nuevo nuevo NameValuePair ("Key", "Interface Security Password"), New NameValuePair ("SmSmob", "Número de teléfono móvil"), New NameValuePair ("SmStext", "Sms Content")}; ExecuneMethod (post); encabezado [] encabezados = post.getResponseHeaders (); int statuscode = post.getStatUscode (); system.out.println ("statuscode:"+statuscode); for (encabezado h: encabezados) {system.out.outs .println (h.ToString ());} string dulter = new String (post.getResponseBodyAsstring (). GetBytes ("GBK"));4.php
$ url = 'http: //sms.webchinese.cn/web_api/? uid = cuenta & key = interface key & smsmob = número móvil y smstext = sms content'; echo get ($ url); function get ($ url) {if (function_exists (' 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_returntransfer, 1); curl_setopt ($ ch, curlopt_connecttimeout, $ timeOut); $ file_contents = curl_exec ($ ch); curl_close ($ ch);} return $ file_contents;}5.vb.net
'Llame para enviar SMS, Nolist para recibir el número de uso múltiple, por separado, el contenido de la nota de 70 palabras Función pública Sendsm .cn/web_api/? uid = cuenta & key = interface key & smSmob = mobile number & smstext = sms content "dim webclient como nuevo net.webclient () intent'dim Responsedata como byte () = dim srcString as string = webClient.downloadString (url) return srcStringChatchratchnreturn "-444" FIN DE TRATED Función
Espero que este artículo sea útil para la programación Java de todos.