zoukankan      html  css  js  c++  java
  • asp.net Twilio

    Imports System.Net
    Imports System.Text
    Imports Twilio
    
    Public Class clsTwilioSMS
    
        Public Shared Function Send(ByVal pToNumber 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.SMSAuthToken.ToString
                Dim FromNumber As String = My.MySettings.Default.SMSFromNumber.ToString
    
                Dim Twilio As TwilioRestClient = New TwilioRestClient(AccountSid, AuthToken)
                Dim message As SMSMessage = Twilio.SendSmsMessage(FromNumber, 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 += " >>>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(p12Filename, True, System.Text.Encoding.UTF8)
                    aa.WriteLine(pLine)
                    aa.Close()
                    aa.Dispose()
                End If
            Catch ex As Exception
            End Try
        End Sub
    
    
    
    
    End Class
    

    主要的Dll:

    http://files.cnblogs.com/files/xiaobuild/TwilioDLL.zip

    参考网站:

    https://www.twilio.com/user/account/developer-tools/api-explorer/message-create

  • 相关阅读:
    LCS 最长公共子序列
    零和数组
    Learn2Rank
    ac自动机
    208. Implement Trie (Prefix Tree)
    php截取中文字符串 GB2312 utf-8
    纵向文字滚动代码,带上下图片控制的。鼠标放到上下图片上时滚动
    js图片切换 带左右控制的
    实时显示输入的内容
    Lightbox JS v2.0图片切换效果
  • 原文地址:https://www.cnblogs.com/xiaobuild/p/4585872.html
Copyright © 2011-2022 走看看