Как получить смс ответ от Twillio с Ms-Access - PullRequest
0 голосов
/ 10 мая 2019

Я хочу получить SMS-ответ клиента с помощью MS-Access на определенную дату (дата создания> 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
...