تصف هذه المقالة طرق تنفيذ وظيفة إرسال الكتلة من SMS بواسطة Java و PHP و C#و ASP. شاركه للرجوع إليه. التفاصيل كما يلي:
أولاً ، انتقل إلى http://www.smschinese.cn/ لتنزيل حزمة الجرة وتسجيل المستخدم ، ثم اتصل بواجهة API للحصول على المفتاح السري
1. مثال استدعاء ASP
<٪ "الوظيفة المشتركة" أدخل عنوان URL لصفحة الويب الوجهة ، وقيمة الإرجاع GethTtPpage هي رمز HTML لوظيفة صفحة الويب الوجهة GethTtppage (url) dim httpset http = server.createBject ("msxml2.xmlhttp") http. افتح "get" ، url ، falsehttp .send () إذا كان http.readyState <> 4 ثم الخروج من وظيفة IfgethTtPage = bytestobstr (http.responseBody ، bytestobstr (body ، cset) dim objstreamset objStream = server.createObject ("adodb.stream") objStream.type = 1OBJStream.mod objstream.closeet ubjstream = nothingend وظيفة "الجمع بين عنوان URL المقدم وأضف حسابك الخاص وكلمة المرور sms_url =" http://sms.webchinese.cn/web_api/؟uid=Account&Key=Interface Key & smsmob = mobile number & smstext = sms content ". اكتب gethtpage (sms_url) ٪>2.C# الاتصال
// مساحة الاسم المطلوبة هي استخدام System.net ؛ باستخدام System.io ؛ باستخدام System.Text ؛ // عند الاتصال ، تحتاج فقط إلى تمرير عنوان URL المكتوبة إلى الوظيفة. ما عليك سوى الحكم على قيمة الإرجاع gethtmlfromurl (url url) {String strret = null ؛ if (url == null || url.trim (). trim (). ؛ hr.timeout = 30 * 60 * 1000 ؛ webresponse hs = hr.getResponse () ؛ Stream sr = hs.getResponsestream () ؛ StreamReader ser = new StreamReader (sr ، charding.default) ؛ strret = ser.readtoend () ؛ } catch (استثناء ex) {strret = null ؛} return strret ؛}3. جافا مكالمة
استيراد java.io.unsupportedencodingexception ؛ استيراد org.apache.commons.httpclient.header ؛ استيراد org.apache.commons.httpclient.httpclient .postmethod ؛ الطبقة العامة sendmsg_webchinese {public static void main (string [] args) استثناء {httpclient client = new httpclient () ؛ postmethod post = new postmethod ("http://gbk.sms.webchinese.cn") ؛ .addrequestheader ("نوع المحتوى" ، "التطبيق/x-www-form-urlencoded ؛ charset = gbk") ؛ // تعيين transcoding namevaluepair [] data = {new nameValuepair ("uid" ، "هذا الموقع المستخدم" ، جديد NameValuepair ("مفتاح" ، "كلمة مرور أمان الواجهة") ، New NameValuepair ("SMSMOB" ، "رقم الهاتف المحمول") ، NEWALDVALUEPAIR ("SMSText" ، "SMS Content")} ؛ executemethod (post) ؛ header [] headers = post.getResponseHeaders () ؛ int statusCode = post.getStatusCod .println (H.ToString ()) ؛} النتيجة string = new string (post.getResponseBondassTring (). getBytes ("gbk") ؛4.php
$ url = 'http: //sms.webchinese.cn/web_api/؟ uid = account & key = key key & smsmob = mobile number & 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_returntrantfer ، 1) ؛ curl_setopt ($ ch ، curlopt_connecttimeout ، $ timeout) ؛ $ file_contents = curl_exec ($ ch) ؛ curl_close ($ ch) ؛} إرجاع $ file_contents ؛}5.vb.net
"دعوة لإرسال الرسائل القصيرة ، Nolist لتلقي الرقم. .cn/web_api/؟ uid = حساب ومفتاح = مفتاح الواجهة و smsmob = رقم الهاتف المحمول و smstext = محتوى sms "dim webclient مثل net.webclient () try'dim revieData as byte () = dim srcString as string = webclient "-444" وظيفة تجربة نهاية
آمل أن يكون هذا المقال مفيدًا لبرمجة Java للجميع.