SMSv2 VB.NET
From CDYNE Wiki for Web Services
- Add a service reference to http://sms2.cdyne.com/sms.svc?wsdl
Simple Sender
Dim client As IsmsClient = New IsmsClient("sms2wsHttpBinding") ' The WS links to your app.config binding names. You can use one of the ones provided by CDYNE ' Simple Sender Console.WriteLine(client.SimpleSMSsend("17575449510", "Test Simple SMS", New Guid("00000000-0000-0000-0000-000000000000")).MessageID.ToString()) client.Close()
Advanced Sender
Dim client As SMS_WSDL.IsmsClient = New SMS_WSDL.IsmsClient("sms2wsHttpBinding") Dim advReq As New SMS_WSDL.SMSAdvancedRequest() Dim smsReqs As List(Of SMS_WSDL.SMSRequest) = New List(Of SMS_WSDL.SMSRequest) Dim req As SMS_WSDL.SMSRequest = New SMS_WSDL.SMSRequest() Dim phoneNumbers As List(Of String) = New List(Of String) advReq.LicenseKey = New Guid("Your License Key") phoneNumbers.Add("17575449510") req.Message = "VB.NET SMS Advanced" req.ReferenceID = "1" ' This could be any id from your system. This is optional. req.StatusPostBackURL = "http://www.cdyne.com/postbacksms.aspx" ' This should point to your server if you plan on postbacks for responses. This is optional. req.PhoneNumbers = phoneNumbers.ToArray() req.ScheduledDateTime = New DateTime(2011, 7, 27, 13, 25, 0).ToUniversalTime 'ScheduledDateTime Format is Year, Month, Date Hour, Minutes, Seconds. The time can be set in your local time zone as it is converted to UTC. smsReqs.Add(req) advReq.SMSRequests = smsReqs.ToArray() Dim smsResp() As SMS_WSDL.SMSResponse = client.AdvancedSMSsend(advReq) Console.WriteLine(smsResp(0).MessageID) client.Close()
Get Message Status
Imports VBapp.SMS Module Module1 Dim WithEvents T As System.Timers.Timer = New System.Timers.Timer(5000) Dim messageID As Guid Dim client As IsmsClient = New IsmsClient("sms2wsHttpBinding") Sub Main() Dim res As SMS.SMSResponse = client.SimpleSMSsend("7575449510", "Hi Tom", Guid.Empty) messageID = res.MessageID T.Start() Console.ReadLine() End Sub Private Sub ttick(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles T.Elapsed Console.WriteLine("Tick") Dim resp As SMS.SMSResponse = client.GetMessageStatus(messageID) If resp.SMSIncomingMessages.Length > 0 Then Console.WriteLine(resp.SMSIncomingMessages(0).Message) T.Stop() Console.WriteLine("Timer Close") End If End Sub End Module
