Imports system.netimports system.textimports twiliopublic Class clstwiliosms public Shared Function Send (ByVal Ptonumbe R As String, ByVal Psmsmessage as String) As String Dim strreturn As String = "0" Dim strlog As String = Now . ToString ("Yyyy-mm-dd HH:mm:ss") & "Send Sms to" & Ptonumber & Vblet Try Dim Accountsid as string = My.MySettings.Default.SMSAccountSid.ToString Dim AuthToken as String = My.MySettings.Default.SMSAuthTo Ken. ToString Dim fromnumber As String = My.MySettings.Default.SMSFromNumber.ToString Dim Twilio As Twili Orestclient = New twiliorestclient (accountsid, AuthToken) Dim message as Smsmessage = Twilio.sendsmsmessage (Fro Mnumber, Ptonumber, Psmsmessage, "") If (message. Sid is Nothing) then strlog + = ">>>send Sms Failed, Detail:" & message. Restexception.tostring Strreturn = "-1" Else strlog + = "; >>send Sms Success, Sid: "& message. Sid & Vblet Strreturn = "1" End If Catch ex as Exception strlog + = ">& Gt;>send Sms Exception, Detail: "& Ex. ToString & Vblet Finally logbyline (strlog) End Try Return strreturn End Function Private Shared Sub logbyline (ByVal pLine as String) Try If Trim (pLine) <> "Then Dim p12file As String = "SMSLog.txt" Dim p12filename As String = System.IO.Path.Combine (System.Web.Hosting. Hostingenvironment.mappath ("~/"), P12file) Dim aa as System.IO.StreamWriter = New System.IO.StreamWriter (p1 2Filename, True, System.Text.Encoding.UTF8) AA. WriteLine (pLine) AA. Close () AA. Dispose () End If Catch ex as Exception end Try End SubEnd Class
The main DLLs:
Http://files.cnblogs.com/files/xiaobuild/TwilioDLL.zip
Reference website:
Https://www.twilio.com/user/account/developer-tools/api-explorer/message-create
ASP. Twilio