この記事では、Java、PHP、C#、およびASPによるSMSの質量送信機能を実装する方法について説明します。参照のためにそれを共有してください。詳細は次のとおりです。
まず、http://www.smschinese.cn/にアクセスしてJARパッケージをダウンロードしてユーザーを登録し、APIインターフェイスに電話してシークレットキーを取得します
1. ASPコールの例
<% 'Common function'宛先WebページのURLを入力すると、gethttppageの返品値は宛先Webページ関数gethttppage(url)dim httpset httpset http = server.createobject( "msxml2.xmlhttp")httpのHTMLコードです。 "get"、url、falsehttp .send()の場合はhttp.readystate <> 4を開きます。functionend iftestobstr(http.responsebody、 "gb2312")set http = nothif err.number <> 0 then err. clear end edr.clear bytestobstr(body、cset)dim objstreamset objstream = server.createobject( "adodb.stream")objstream.type = 1objstream.mode = 3objstream.openobjstream. objstream.closeSet objStream = noweend関数 '送信されたURLを組み合わせて、独自のアカウントとパスワードを追加するsms_url = "http://sms.web_api/?uid = account&key = interface key&smsmob =携帯番号gethttppage(sms_url)%>を書き込みます
2.C#呼び出し
//必要な名前空間は、System.net;を使用することです。System.io;を使用しています。System.Text; //呼び出しの場合、スペルのURLを関数に渡すだけです。 return Value Public String 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(互換; msie 6.0; windows nt 5.1)"; hr.method = "get" ; hr.timeout = 30 * 60 * 1000; webresponse hs = hr.getResponse(); stream sr = hs.getResponseStream(); streamreader ser = new streamReader(sr、encoding.default); strret = ser.readtoend(); } catch(Exception ex){strret = null;} return strret;}3.Javaコール
java.io.unsupportedencodingception; import org.apache.commons.httpclient.header; Import org.apache.commons.httpclient.httpclient; Import org.apache.commons.httpclient.namevaluepair; import.apach.commons.httpcl. .postmethod; public class sendmsg_webchinese {public static void main(string [] args)throws {httpclient client = new httpclient(); postmethod post = new postmethod( "http://gbk.sms.webchinese.cn"); .AddRequestHeader( "content-type"、 "application/x-www-form-urlencoded; charset = gbk"); // transcoding namevaluepair [] data = {new namevaluepair( "uid"、 "このサイトユーザー名"、new namevaluepair( "key"、 "interface security password")、new namevaluepair( "smsmob"、 "携帯電話番号")、new namevaluepair( "smstext"、 "sms content")}; executeMethod(post); header [] headers = post.getResponseHeaders(); int statusCode = post.getStatusCode(); system.out.println( "statusCode:"+statusCode); for(header H:headers){system.out .println(h.toString());} string result = new String(post.getResponseBodyAsstring()。getBytes( "gbk"));4.PHP
$ url = 'http://sms.webchinese.cn/web_api/?uid = account&key = interface key&smsmob =携帯番号&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_connecttimeout、$ timeout); $ file_contents = curl_exec($ ch); curl_close($ ch);} return $ file_contents;}5.vb.net
「SMS、NOLISTを送信して、複数の使用、メモコンテンツ70ワードパブリック機能(byval nolist、byval memo as string)as string = "http://sms.webchinese .cn/web_api/?uid = account&key = interface key&smsmob = mobile number&smstext = smsコンテンツ "dim webclient" new net.webclient()try'dim ressonsedata as byte "-444" end tryend関数
この記事がみんなのJavaプログラミングに役立つことを願っています。