如何使用Ms-Access从Twillio获得短信回复

时间:2019-05-10 20:40:26

标签: ms-access sms twilio

我希望从特定日期(datecreation> 2019-01-01

我收到所有短信答复,并且CSV格式不好。

示例:

"Sun, 31 Mar 2019 15:25:05 +0000",

代码:

Const ACCOUNTSID As String = "AC9999999999999999999999999"
Const AUTHTOKEN As String = "00000000000000000000000000000"
Const BASEURL As String = "https://api.twilio.com"

Function ReceiveMessage() 'TWILIO
   Dim MessageUrl As String
   Dim objHTTP As Object
   Dim Response As Object
   Dim VarDemande As String
   Dim stm As Object
   Dim strFilePath As String

   On Error GoTo Error_Handler
   MessageUrl = BASEURL & "/2010-04-01/Accounts/" & ACCOUNTSID & "/Messages" & ".csv"

   Dim http As MSXML2.XMLHTTP60
   Set http = New MSXML2.XMLHTTP60
   http.Open "GET", MessageUrl, False, ACCOUNTSID, AUTHTOKEN
   http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

   VarDemande = "DateCreated>=2019-01-01"    ' DateSent>=YYYY-MM-DD 42
   http.send VarDemande

   strFilePath = CurrentProject.Path & "\TEST.csv"
   Set stm = CreateObject("ADODB.Stream")
   stm.Type = 2  ' acTypeText
   stm.Open
   stm.WriteText http.responseText
   stm.SaveToFile strFilePath, 2   'adSaveCreateOverWrite
   stm.Close

Exit_Procedure:
    On Error Resume Next
    Set http = Nothing

Exit Function

Error_Handler:

    Select Case Err.Number
         Case Else
            MsgBox "Error: " & Err.Number & "; Description: " & Err.Description
            Resume Exit_Procedure
        Resume

    End Select
End Function

0 个答案:

没有答案