Docy

Did You Know?

ASP.NET Sample Code (GET)

                                        
                                            
                                    <%@ Import Namespace="System.Net" %>
                                    <%@ Import Namespace="System.IO" %>
                                    
                                    <script runat="server" language="VB">
                                                                                
                                        Sub Page_Load(sender As Object, e As EventArgs)
                                        
                                        Dim apiKey As String        = "your apiKey"
                                        Dim SenderName As String    = "MyName"
                                        Dim Number As String        = "923186373741,923186373741,923186373741"
                                        Dim Message As String       = "This is an API message"
                                        
                                        Dim URL As String = "https://www.echosofts.com/api/sendsms.php?apikey=" & apiKey & "&sender=" & SenderName & "&phone=" & Number & "&message=" & Message
                                        Dim req As HttpWebRequest = WebRequest.Create(URL)
                                        
                                        Try
                                            Dim resp As HttpWebResponse = req.GetResponse()
                                            Dim sr As New StreamReader(resp.GetResponseStream())
                                            Dim results As String = sr.ReadToEnd()
                                            sr.Close()
                                        
                                            html.Text = results
                                        Catch wex As WebException
                                        Response.Write("SOMETHING WENT AWRY!
                                        Status: " & wex.Status & "Message: " & wex.Message & "")
                                        End Try
                                        End Sub
                                                                                
                                    </script>
                                        
                                    

ASP.NET Sample Code (POST)

                                        
                                            
                                            <%@ Import Namespace="System.Net" %>
                                            <%@ Import Namespace="System.IO" %>
                                            
                                            <script runat="server" language="VB">
                                                                                        
                                                Dim apikey As String = "YourapiKey"
                                            
                                                    Dim SenderName As String    = "MyName"
                                                    Dim Number As String        = "447123456789"
                                                    Dim Message As String       = "This is an API message"
                                                    Dim URL As String           = "https://www.echosofts.com/api/sendsms.php?"
                                                    Dim PostData As String      = "apikey=" & apikey & "&sender=" & SenderName & "&phone=" & Number & "&message=" & Message
                                                    Dim req As HttpWebRequest = WebRequest.Create(URL)
                                                    req.Method = "POST"
                                                    Dim encoding As New ASCIIEncoding()
                                                    Dim byte1 As Byte() = encoding.GetBytes(PostData)
                                                    req.ContentType = "application/x-www-form-urlencoded"
                                                    req.ContentLength = byte1.Length
                                                    Dim newStream As Stream = req.GetRequestStream()
                                                    newStream.Write(byte1, 0, byte1.Length)
                                            
                                                    Try
                                                        Dim resp As HttpWebResponse = req.GetResponse()
                                                        Dim sr As New StreamReader(resp.GetResponseStream())
                                                        Dim results As String = sr.ReadToEnd()
                                                        sr.Close()
                                                        html.Text = results
                                                    Catch wex As WebException
                                            	  Response.Write("SOMETHING WENT AWRY!
                                                  Status: " & wex.Status & "Message: " & wex.Message & "")
                                                End Try
                                                End Sub
                                            
                                                                                        
                                            </script>
                                        
                                    
CONTENTS