Einfache SMS senden
SOAP 1.1
Es folgt ein Beispiel für eine SOAP 1.1-Anforderung und -Antwort. Die angezeigten Platzhalter müssen durch tatsächliche Werte ersetzt werden.
POST /gateway/send.asmx HTTP/1.1
Host: www.smscreator.de
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.smscreator.de/gateway/SendSimpleSMS"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendSimpleSMS xmlns="http://www.smscreator.de/gateway">
<User>string</User>
<Password>string</Password>
<Caption>string</Caption>
<Sender>string</Sender>
<Recipient>string</Recipient>
<SMSText>string</SMSText>
<SmsTyp>Flash or Standard or StandardDeliveryNotification or StandardLong or HighQuality or HighQualityLong or PSTNFixedLine</SmsTyp>
<SendDate>string</SendDate>
</SendSimpleSMS>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <SendSimpleSMSResponse xmlns="http://www.smscreator.de/gateway"> <SendSimpleSMSResult> <StatusCode>None or Ok or InvalidUser or AccountLocked or IPLock or DatabaseError</StatusCode> <Value> <Status>None or Ok or NoTextFound or NoDataFound or NoUrlFound or NoRecipientFound or SMSTypeError or DuplicateSMSJobFound or ShortIDAsSenderFound or LoginError or UnknowError or DatabaseError or JobIsQueuedInsufficientCredits</Status> <JobId>int</JobId> </Value> </SendSimpleSMSResult> </SendSimpleSMSResponse> </soap:Body> </soap:Envelope>
SOAP 1.2
Es folgt ein beispiel für eine SOAP 1.2-Anforderung und -Antwort.Die angezeigten Platzhalter müssen durch tatsächliche Werte ersetzt werden.
POST /gateway/send.asmx HTTP/1.1 Host: www.smscreator.de Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <SendSimpleSMS xmlns="http://www.smscreator.de/gateway"> <User>string</User> <Password>string</Password> <Caption>string</Caption> <Sender>string</Sender> <Recipient>string</Recipient> <SMSText>string</SMSText> <SmsTyp>Flash or Standard or StandardDeliveryNotification or StandardLong or HighQuality or HighQualityLong or PSTNFixedLine</SmsTyp> <SendDate>string</SendDate> </SendSimpleSMS> </soap12:Body> </soap12:Envelope>
HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <SendSimpleSMSResponse xmlns="http://www.smscreator.de/gateway"> <SendSimpleSMSResult> <StatusCode>None or Ok or InvalidUser or AccountLocked or IPLock or DatabaseError</StatusCode> <Value> <Status>None or Ok or NoTextFound or NoDataFound or NoUrlFound or NoRecipientFound or SMSTypeError or DuplicateSMSJobFound or ShortIDAsSenderFound or LoginError or UnknowError or DatabaseError or JobIsQueuedInsufficientCredits</Status> <JobId>int</JobId> </Value> </SendSimpleSMSResult> </SendSimpleSMSResponse> </soap12:Body> </soap12:Envelope>
HTTP GET
Folgendes ist eine Beispielanforderung und -antwort für HTTP GET. Die angezeigten Platzhalter müssen durch richtige Werte ersetzt werden.
GET /gateway/send.asmx/SendSimpleSMS?User=string&Password=string&Caption=string&Sender=string&Recipient=string&SMSText=string&SmsTyp=string&SendDate=string HTTP/1.1 Host: www.smscreator.de
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <SOAPResponseOfCreateJobInfo xmlns="http://www.smscreator.de/gateway"> <StatusCode>None or Ok or InvalidUser or AccountLocked or IPLock or DatabaseError</StatusCode> <Value> <Status>None or Ok or NoTextFound or NoDataFound or NoUrlFound or NoRecipientFound or SMSTypeError or DuplicateSMSJobFound or ShortIDAsSenderFound or LoginError or UnknowError or DatabaseError or JobIsQueuedInsufficientCredits</Status> <JobId>int</JobId> </Value> </SOAPResponseOfCreateJobInfo>
HTTP POST
Folgendes ist eine Beispielanforderung und -antwort für HTTP POST. Die angezeigten Platzhalter müssen durch richtige Werte ersetzt werden.
POST /gateway/send.asmx/SendSimpleSMS HTTP/1.1 Host: www.smscreator.de Content-Type: application/x-www-form-urlencoded Content-Length: length User=string&Password=string&Caption=string&Sender=string&Recipient=string&SMSText=string&SmsTyp=string&SendDate=string
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <SOAPResponseOfCreateJobInfo xmlns="http://www.smscreator.de/gateway"> <StatusCode>None or Ok or InvalidUser or AccountLocked or IPLock or DatabaseError</StatusCode> <Value> <Status>None or Ok or NoTextFound or NoDataFound or NoUrlFound or NoRecipientFound or SMSTypeError or DuplicateSMSJobFound or ShortIDAsSenderFound or LoginError or UnknowError or DatabaseError or JobIsQueuedInsufficientCredits</Status> <JobId>int</JobId> </Value> </SOAPResponseOfCreateJobInfo>
Beispiel_2.php
function PostToHost($host, $path, $data_to_send) { // Verwendet HTTPS $fp = fsockopen('ssl://' . $host, 443); fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data_to_send); $res = ""; while(!feof($fp)) { $res .= fgets($fp, 128); } fclose($fp); return $res; } function SendSMS($user,$pw,$jobid,$Msg,$Rcp,$MsgTyp,$Sender) { $Msg = rawurlencode(utf8_encode($Msg)); // Ersetzen Euro Zeichen da PHP das falsch Codiert. $Msg = str_replace("%C2%80","%E2%82%AC",$Msg); // Vorbereiten der Daten $data = "User=$user&Password=$pw&Caption=" . rawurlencode($jobid) . "&Sender=" . rawurlencode($Sender) . "&SMSText=" . $Msg . "&Recipient=" . rawurlencode($Rcp) . "&SmsTyp=$MsgTyp&SendDate="; // Senden an den Server $x = PostToHost("www.smscreator.de","/gateway/Send.asmx/SendSimpleSMS", $data); // Auswerten des Ergebnisses return "Status: " .ParseXML($x,"Status") ."<br>JobID: " .ParseXML($x,"JobId") ; } function ParseXML($msg,$token) { $iStart = strpos($msg,"<" . $token . ">") + strlen($token) +2; $y = substr($msg,$iStart); $iEnde = strpos($y,"</". $token . ">"); return substr($y,0,$iEnde); }
sendsms_http-get.pl
sub sendsms { my ($User, $Password,$Msg,$Recipient,$SMSType,$Sender,$DateTime,$Caption) = @_; my @res = split(",",$Recipient); $Msg = substr($Msg, 0, 160); # GET /Send.asmx/SendText?User=string&Password=string&Caption=string&Sender=string&Recipient=string&SMSText=string&SmsTyp=string&SendDate=string HTTP/1.1 # Host: soap.smscreator.de my $Uri = "http://soap.smscreator.de/Send.asmx/SendText"; $Uri .= "?User=" . uri_escape($User); $Uri .= "&Password=" . uri_escape($Password); $Uri .= "&Caption=" . uri_escape($Caption); $Uri .= "&Sender=" . uri_escape($Sender); $Uri .= "&SMSText=" . uri_escape($Msg); $Uri .= "&SmsTyp=" . uri_escape($SMSType); $Uri .= "&SendDate=" . uri_escape($DateTime); $Uri .= "&Recipient=" . uri_escape(join("\n",@res)); my $res = ""; my $ua = LWP::UserAgent->new(); my $request = HTTP::Request->new('GET', $Uri); my $response = $ua->request($request); if ( $response->is_error() ) { $res .= "Error-Code : ", $response->code() , "\n"; $res .= "Fehlermeldung: ", $response->message() , "\n"; } else { if ($response->content()=~ /SendSMS\">(.*)<\/string>/) { $res = $1; } else { $res = $response->content(); } } return $res; }
SMSSample.asp
<html> <html> <body> <%@ Page AspCompat=true %> <% Response.Buffer = True Dim User dim Password dim Recipient dim SMSMsg User = "test" Password = "test" Recipient="01711234567" SMSMsg="Test MSG aus ASP" Dim xml, text,strURL xml = Server.CreateObject("Microsoft.XMLHTTP") 'Or if this doesn't work then try : 'Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP") strURL = "http://www.smscreator.de/gateway/send.asmx/SendSimpleSMS" strURL = strUrl & "?User=" & Server.URLEncode(User) strURL = strURL & "&Password=" & Server.UrlEncode(Password) strURL = strURL & "&Caption=Test" strURL = strURL & "&Sender=" strURL = strUrl & "&Recipient=" & Server.URLEncode(Recipient) strURL = strURL & "&SMSText=" & Server.UrlEncode(SMSMsg) strURL = strURL & "&SmsTyp=Standard" strURL = strURL & "&SendDate=" xml.Open("GET", strURL, False) xml.Send text = xml.ResponseText Response.write(text) xml = Nothing %> </body> </html>
Borland6 TNM HTTP - USendSMS.cpp
AnsiString sUrl = "/send.asmx/SendText?"; AnsiString sUrl = "/gateway/Send.asmx/SendSimpleSMS?"; sUrl += "User=" + URLEncode(edUser->Text); sUrl += "&Password=" + URLEncode(edPassword->Text); sUrl += "&Caption=" + URLEncode(edCaption->Text); sUrl += "&Sender=" + URLEncode(edSender->Text); sUrl += "&Recipient=" + URLEncode(edRecipient->Text); sUrl += "&SMSText=" + URLEncode(mSMSText->Text); if (cbSmsTyp->ItemIndex == 0) sUrl += "&SmsTyp=6"; else sUrl += "&SmsTyp=18"; sUrl += "&SendDate=" + URLEncode(edSendDate->Text); NMHTTP1->Host = "www.smscreator.de"; NMHTTP1->Get(sUrl); AnsiString sReturn = NMHTTP1->Body; mAntwort->Text = sReturn;
Borland6 WSDL Import - USendSMS.cpp
int iSMSTyp = 6; if (cbSmsTyp->ItemIndex == 0) iSMSTyp = 18; _di_SendSoap soap = GetSendSoap(false,""); AnsiString sReturn = soap->SendText(edUser->Text ,edPassword->Text ,edCaption->Text ,edSender->Text ,edRecipient->Text ,mSMSText->Text , iSMSTyp , edSendDate->Text ); mAntwort->Text = sReturn;
Java Modul (axis1) - SoapConnectorTest.java
public void sendText() throws Exception { InputStreamReader isr = new InputStreamReader(System.in, Charset.forName("ISO-8859-1")); BufferedReader input = new BufferedReader(isr); System.out.print("User: "); String user = input.readLine().trim(); System.out.print("Password: "); String pw = input.readLine().trim(); System.out.print("Caption: "); String caption = input.readLine().trim(); System.out.print("Receipient: "); String receipeint = input.readLine().trim(); System.out.print("Text: "); String text = input.readLine().trim(); try { System.out.println("Sending SMS"); de.smscreator.www.gateway.Send service = new de.smscreator.www.gateway.SendLocator(); de.smscreator.www.gateway.SendSoap sendSoap = service.getSendSoap(); sendSoap.sendSimpleSMS(new de.smscreator.www.gateway.SendSimpleSMS(user, pw, caption, "", receipeint, text, de.smscreator.www.gateway.SmsTextTyp.Standard, "")); System.out.println("SMS successfully sent."); } catch (Exception ex) { System.out.println("Error while sending SMS: " + ex.getMessage()); } }
Form1.vb
Try Dim mySend As New de.smscreator.www1.Send Dim myResult As de.smscreator.www1.SOAPResponseOfCreateJobInfo REM Simple Send Message to Server myResult = mySend.SendSimpleSMS(txtUser.Text, txtPassword.Text, "Test", "", txtRecp.Text, txtMsg.Text, de.smscreator.www1.SmsTextTyp.Standard, "") REM Check Result If myResult.StatusCode <> de.smscreator.www1.LoginStatus.Ok Then MessageBox.Show("Error: " & myResult.StatusCode) Else MessageBox.Show("Message Send\r\nJobID: " & myResult.Value.JobId) End If Catch ex As Exception MessageBox.Show("Error: " & ex.Message) End Try
SimpleSend.vbs
' Function to send the SMS ' <SmsTyp>Flash or Standard or StandardDeliveryNotification or StandardLong or HighQuality or HighQualityLong or PSTNFixedLine</SmsTyp> ' To Use Sender field SMSTyp must be HighQuality or HighQualityLong ' Read more about SMSType: http://www.smscreator.de/t-smstypen.aspx Function SendSMS(user, password, recipient, msg, sender, smstyp, senddate) Dim oweb Set oweb = CreateObject("MSXML2.XMLHTTP") Dim url dim dataparam ' To enable Secure Transmission use https url = "https://www.smscreator.de/GATEWAY/Send.asmx/SendSimpleSMS" ' url = "http://www.smscreator.de/GATEWAY/Send.asmx/SendSimpleSMS" dataparam = "User=" & user & "&Password=" & password & "&Caption=msxml&Sender=" & URLEncode(sender) & "&Recipient=" & URLEncode(recipient) & "&SMSText=" & URLEncode(msg) & "&SmsTyp=" & smstyp & "&SendDate=" & senddate oweb.Open "Post", url, False oweb.setRequestHeader "Content-type", "application/x-www-form-urlencoded" oweb.setRequestHeader "Content-length", len(dataparam) oweb.setRequestHeader "Connection", "close" oweb.send dataparam SendSMS = ParseResult(oweb.responseXML.XML) End Function ' Parse the Result an returns JobId or -1 if an error Function ParseResult(strresult) Dim ores Set ores = CreateObject("MSXML2.DOMDocument") ores.LoadXML strresult If UCase(ores.getElementsByTagName("StatusCode").Item(0).Text) = "OK" Then ParseResult = CLng(ores.getElementsByTagName("JobId").Item(0).Text) Else ' To Show the Error Debug.Print strresult ParseResult = -1 End If End Function Private Function URLEncode(txt) Dim i Dim ch Dim ch_asc Dim result result = "" For i = 1 To Len(txt) ' Translate the next character. ch = Mid(txt, i, 1) ch_asc = Asc(ch) If ch = "�" Then result = result & "%C3%A4" ElseIf ch = "�" Then result = result & "%C3%84" ElseIf ch = "�" Then result = result & "%C3%B6" ElseIf ch = "�" Then result = result & "%C3%96" ElseIf ch = "�" Then result = result & "%C3%BC" ElseIf ch = "�" Then result = result & "%C3%9C" ElseIf ch = "�" Then result = result & "%C3%9F" ElseIf ch_asc = " " Then ' Use a plus. result = result & "+" ElseIf IsSafeChar(ch_asc) Then ' Use the character. result = result & ch Else ' Convert the character to hex. result = result & "%" & Right("0" & Hex(ch_asc), 2) End If Next URLEncode = result End Function Function IsSafeChar(ix) If (ix > -1 And ix < 48) Then IsSafeChar = False ElseIf (ix > 47 And ix < 58) Then IsSafeChar = True ElseIf (ix > 57 And ix < 65) Then IsSafeChar = False ElseIf (ix > 64 And ix < 97) Then IsSafeChar = True ElseIf (ix > 96 And ix < 123) Then IsSafeChar = True Else IsSafeChar = False End If End Function
frmSendSMS.cs
try { de.smscreator.www1.SOAPResponseOfCreateJobInfo sResult = mySend.SendSimpleSMS( txtUser.Text, txtPass.Text, "Test", "", txtRecipients.Text, txtMessage.Text, de.smscreator.www1.SmsTextTyp.Standard, ""); if(sResult.StatusCode == de.smscreator.www1.LoginStatus.Ok) MessageBox.Show("SMS succesfully send. (JobID: " + sResult.Value.JobId + ")"); else MessageBox.Show("Error on send: " + sResult.StatusCode); } catch (Exception ee) { MessageBox.Show("Error: " + ee.Message); }
ruby.rb
#!/usr/bin/env ruby # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42): # <marius@nuenneri.ch> wrote this file. As long as you retain this notice you # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return. Marius Nuennerich # ---------------------------------------------------------------------------- require 'optparse' require 'uri' require 'net/http' require 'active_support/core_ext/hash' options = {} OptionParser.new do |opts| opts.on("-u USERNAME", "", "Login username") do |o| options[:user] = o end opts.on("-p PASSWORD", "", "Login password") do |o| options[:password] = o end opts.on("-r RECIPIENT", "", "Recipient Number") do |o| options[:recipient] = o end opts.on("-m MESSAGE", "", "Message (160 chars max)") do |o| options[:message] = o end end.parse! user = URI.escape "test" #options[:user] password = URI.escape "test" #options[:password] recipient = URI.escape "0170123456789" #options[:recipient] message = URI.escape "Testnachricht" #options[:message][0..159] type = 6 # Rueck-SMS caption = "" sender = "" date = "" uri = "http://www.smscreator.de/gateway/Send.asmx/SendSimpleSMS?" + "User=#{user}&Password=#{password}&Caption=#{caption}&" + "Sender=#{sender}&Recipient=#{recipient}&SMSText=#{message}" + "&SmsTyp=#{type}&SendDate=#{date}" res = Net::HTTP.get(URI.parse(uri)) hash = Hash.from_xml(res) status = hash["SOAPResponseOfCreateJobInfo"]["StatusCode"] value = hash["SOAPResponseOfCreateJobInfo"]["Value"]["JobId"] puts "Status: " + status + "\tJobID: " + value
cmdSendSMS.exe
cmdSendSMS.exe /User:Serienummer /PW:Password /RCP:01701234567 /text:"TestSMS über SMSCreator" cmdSendSMS.exe /User:Serienummer /PW:Password /RCP:01701234567 ’/text:"TestSMS über SMSCreator"’
winSendSMS.exe
winSendSMS.exe /User:Serienummer /PW:Password /RCP:01701234567 /text:"TestSMS über SMSCreator" /ProcessMode:Console winSendSMS.exe /User:Serienummer /PW:Password /RCP:01701234567 ’/text:"TestSMS über SMSCreator"’
python.py
#!/usr/bin/python2.5 import urllib2 import urllib import ssl import time send_ret = '' ret_status = False sms_recipient = '171xxxxxxxxxx' smstext = 'test sms text' sms_baseurl = 'https://www.smscreator.de/gateway/Send.asmx/SendSMS' sms_user = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' sms_pass = 'xxxxxxxxxxxxxxxxx' sms_caption = 'test' sms_sender = '0171xxxxxxxxxxxx' sms_type = '6' # standard sms (160 chars): 6 send_date = time.strftime('%Y-%m-%dT%H:%M:%S') request_map = { 'User': sms_user, 'Password': sms_pass, 'Caption' : sms_caption, 'Sender' : sms_sender, 'SMSText' : smstext, 'Recipient' : sms_recipient, 'SmsTyp' : sms_type, 'SendDate' : send_date } txdata = urllib.urlencode(request_map) txheaders = {} try: filehandle = urllib2.urlopen(sms_baseurl, txdata) send_ret = filehandle.read() filehandle.close() ret_status = True except Exception, e: print 'Error happend: %s'%str(e) if ret_status: print 'Status: SMS to %s send succeeded.' % str(sms_recipient) else: print 'Status: SMS to %s send failed.' % str(sms_recipient) print 'Return data: %s' % str(send_ret)
python3.py
#!/usr/bin/python3.2 import urllib.request, urllib.error, urllib.parse import urllib.request, urllib.parse, urllib.error import ssl import time send_ret = '' ret_status = False sms_recipient = '171xxxxxxxxxx' smstext = 'test sms text' sms_baseurl = 'https://www.smscreator.de/gateway/Send.asmx/SendSMS' sms_user = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' sms_pass = 'xxxxxxxxxxxxxxxxx' sms_caption = 'test' sms_sender = '0171xxxxxxxxxxxx' sms_type = '6' # standard sms (160 chars): 6 send_date = time.strftime('%Y-%m-%dT%H:%M:%S') request_map = { 'User': sms_user, 'Password': sms_pass, 'Caption' : sms_caption, 'Sender' : sms_sender, 'SMSText' : smstext, 'Recipient' : sms_recipient, 'SmsTyp' : sms_type, 'SendDate' : send_date } txdata = urllib.parse.urlencode(request_map) txdata = txdata.encode("utf-8") txheaders = {} try: filehandle = urllib.request.urlopen(sms_baseurl, txdata) send_ret = filehandle.read() filehandle.close() ret_status = True except Exception as e: print('Error happend: %s'%str(e)) if ret_status: print('Status: SMS to %s send succeeded.' % str(sms_recipient)) else: print('Status: SMS to %s send failed.' % str(sms_recipient)) print('Return data: %s' % str(send_ret))
main.pas
var sResult : string; sRec : string; begin sRec:= StringReplace(Rec_Memo.Text, ',', #13#10, [rfReplaceAll, rfIgnoreCase]); if IniSimple then begin try sResult:= (HTTPRIO1 as SendSoap).SendSimpleSMS(WideString(User_Edit.Text), WideString(Pw_Edit.Text), WideString(sRec), WideString(Msg_Memo.Text), ); DoAddLogMemo('>>>>> send simple SMS : '+ sResult); except on E: Exception do begin DoAddLogMemo('General Error -' + E.Message); end; end; end else begin try sResult:= (HTTPRIO1 as SendSoap).SendText(WideString(User_Edit.Text), WideString(Pw_Edit.Text), WideString(Caption_Edit.Text), WideString(Sender_Edit.Text), WideString(sRec), WideString(Msg_Memo.Text), WideString('18'), WideString(DateTimeToStr(Now)) ); DoAddLogMemo('>>>>> send SMS : '+ sResult); except on E: Exception do begin DoAddLogMemo('General Error -' + E.Message); end; end; end; end;
Rufen Sie uns an.
Lösungen finden