台灣簡訊
http://ui.twsms.com/index.php?page=dl_doc.htm
發送url
http://api.twsms.com/send_sms.php?username=0912754176&password=12121221&type=now&encoding=big5&mobile=0912754176&message=傳送內容 Test Sms 123&vldtme=3600
============================
Imports System.IO
Imports System.Net
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
' =============主程式=利用WWW連線方式(GET)傳送簡訊=======================
'Dim strURL As String = ""
'Dim userID As String = "*帳號*"
'Dim password As String = "*密碼*"
'Dim m_num As String = "*手機號嗎*"
'Dim message As String = "*傳送內容*"
Dim strURL As String = ""
Dim userID As String = "0912754176"
Dim password As String = "12121221"
Dim m_num As String = "0912754176"
Dim message As String = "傳送內容 Test Sms 123"
strURL = "http://api.twsms.com/send_sms.php?username=" & userID _
& "&password=" & password & "&type=now&encoding=big5&mobile=" & m_num _
& "&message=" & message & "&vldtme=3600"
Dim myHttpWebRequest As HttpWebRequest
Dim myHttpWebResponse As HttpWebResponse
Try
myHttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
GetResponseData(myHttpWebResponse.GetResponseStream())
myHttpWebResponse.Close()
Catch ex As Exception
End Try
End Sub
'======================副程式=====接收對方的回應,儲存在文字檔內=========
Private Sub GetResponseData(ByVal myStream As Stream)
Dim mypath = "D:\mytest.txt" '儲存位置
Dim sw2 As StreamWriter = New StreamWriter(mypath, True, System.Text.Encoding.Default)
Dim myStreamReader As StreamReader = New StreamReader(myStream, System.Text.Encoding.Default)
Dim strOut As String = myStreamReader.ReadToEnd()
Try
sw2.WriteLine(strOut)
sw2.Close()
myStreamReader.Close()
Catch
myStreamReader.Close()
sw2.Close()
End Try
End Sub
End Class
http://ui.twsms.com/index.php?page=dl_doc.htm
發送url
http://api.twsms.com/send_sms.php?username=0912754176&password=12121221&type=now&encoding=big5&mobile=0912754176&message=傳送內容 Test Sms 123&vldtme=3600
============================
Imports System.IO
Imports System.Net
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
' =============主程式=利用WWW連線方式(GET)傳送簡訊=======================
'Dim strURL As String = ""
'Dim userID As String = "*帳號*"
'Dim password As String = "*密碼*"
'Dim m_num As String = "*手機號嗎*"
'Dim message As String = "*傳送內容*"
Dim strURL As String = ""
Dim userID As String = "0912754176"
Dim password As String = "12121221"
Dim m_num As String = "0912754176"
Dim message As String = "傳送內容 Test Sms 123"
strURL = "http://api.twsms.com/send_sms.php?username=" & userID _
& "&password=" & password & "&type=now&encoding=big5&mobile=" & m_num _
& "&message=" & message & "&vldtme=3600"
Dim myHttpWebRequest As HttpWebRequest
Dim myHttpWebResponse As HttpWebResponse
Try
myHttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)
myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
GetResponseData(myHttpWebResponse.GetResponseStream())
myHttpWebResponse.Close()
Catch ex As Exception
End Try
End Sub
'======================副程式=====接收對方的回應,儲存在文字檔內=========
Private Sub GetResponseData(ByVal myStream As Stream)
Dim mypath = "D:\mytest.txt" '儲存位置
Dim sw2 As StreamWriter = New StreamWriter(mypath, True, System.Text.Encoding.Default)
Dim myStreamReader As StreamReader = New StreamReader(myStream, System.Text.Encoding.Default)
Dim strOut As String = myStreamReader.ReadToEnd()
Try
sw2.WriteLine(strOut)
sw2.Close()
myStreamReader.Close()
Catch
myStreamReader.Close()
sw2.Close()
End Try
End Sub
End Class
全站熱搜
留言列表