Docy

Did You Know?

VB.NET Sample Code (GET)

                                        

                                   Imports System.Net
                        Imports System.Web
                        Imports System.Collections.Specialized
                        Imports System.IO
                        Imports System.Text
                        
                        Public Class sendSMS
                        
                            Public Function sendSMS()
                        
                                Dim apikey = "yourapiKey"
                                Dim message = "This is your message"
                                Dim phone = "923186373741,923186373741,923186373741"
                                Dim strGet As String
                                Dim sender = "SmartSMS"
                                Dim url As String = "https://www.echosofts.com/api/sendsms.php?"
                        
                                strGet = url + "apikey=" + apikey _
                                + "&phone=" + phone _
                                + "&message=" + WebUtility.UrlEncode(message) _
                                + "&sender=" + sender
                        
                                Dim webClient As New System.Net.WebClient
                                Dim result As String = webClient.DownloadString(strGet)
                                Console.WriteLine(result)
                                Return result
                            End Function
                        End Class
                                    
                                    
                                    

VB.NET Sample Code (POST)

                                        
                                       

                                   Imports System.Web
                                Imports System.IO
                                Imports System.Net
                                Imports System.Text
                                Imports System.Resources
                                
                                Public Class sendSMS
                                
                                    Public Function sendSMS()
                                        Dim apikey = "yourAPIkey"
                                        Dim message = "This is your message"
                                        Dim phone = "923186373741,923186373741,923186373741"
                                        Dim strPost As String
                                        Dim sender = "SmartSMS"
                                        Dim url As String = "https://www.echosofts.com/api/sendsms.php?"
                                        Dim strPost As String
                                
                                        strPost = url + "apikey=" + apikey _
                                        + "&phone=" + phone _
                                        + "&message=" + WebUtility.UrlEncode(message) _
                                        + "&sender=" + sender
                                
                                        Dim request As WebRequest = WebRequest.Create(strPost)
                                        request.Method = "POST"
                                        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(strPost)
                                        request.ContentType = "application/x-www-form-urlencoded"
                                        request.ContentLength = byteArray.Length
                                        Dim dataStream As Stream = request.GetRequestStream()
                                        dataStream.Write(byteArray, 0, byteArray.Length)
                                        dataStream.Close()
                                
                                        Dim response As WebResponse = request.GetResponse()
                                        dataStream = response.GetResponseStream()
                                        Dim reader As New StreamReader(dataStream)
                                        Dim responseFromServer As String = reader.ReadToEnd()
                                        Console.WriteLine(responseFromServer)
                                        Console.ReadLine()
                                
                                        reader.Close()
                                        dataStream.Close()
                                        response.Close()
                                
                                        If responseFromServer.Length > 0 Then
                                            Return responseFromServer
                                        Else
                                            Return CType(response, HttpWebResponse).StatusDescription
                                        End If
                                    End Function
                                End Class
                                    
                                    
                                         
                                    
CONTENTS