Imports System.IO
Imports System.Net
Imports System.Net.WebRequest
Imports System.Net.WebResponse
Private Function SendSMS_txtLocal(ByVal Test As Boolean, _
ByVal iFrom As String, _
ByVal Message As String, _
ByVal SendTo As String, _
ByVal URL As String) As String
Const TransportURL As String = "http://www.inanosms.com/API_NANO_NAME_V2.ASP"
Const TransportUserName As String = "Register Username"
Const TransportPassword As String = "mypassword"
Const SMode As String = "E" ' ภาษาที่ใช้ส่ง
Dim strPost As String
strPost = "Username=" + TransportUserName _
+ "&Password=" + TransportPassword _
+ "&Text=" + Message _
+ "&Sname=" + iFrom _
+ "&SMSMode=" + SMode _
+ "&Phonenumber=" + SendTo
Dim request As WebRequest = WebRequest.Create(TransportURL)
request.Method = "POST"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(strPost) ' Create POST
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()
' Get the response.
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
' Clean up the streams.
reader.Close()
dataStream.Close()
response.Close()
' Return result to calling function
If responseFromServer.Length > 0 Then
Return responseFromServer
Else
Return CType(response, HttpWebResponse).StatusDescription
End If
End Function