cal*_*eer 2 ms-access access-vba ms-access-2010 twilio
我做了很多研究,但我什么都没发现.反正已经这样做了吗?任何例子?
我想使用表单中的按钮发送消息,因此它应该调用vba代码并使用相同表单中的某些信息来发送消息.任何想法都会很棒!!
我正在使用Access 2010
Twilio福音传教士在这里.
简而言之,您需要使用VBA POST到Twilio REST API.
以下是一些示例代码,演示了如何使用XMLHTTP执行此操作:
Public Function GET_MESGS()
Dim Message As String
Dim Number As String
On Error GoTo Error_Handler
Const NOINTERNETAVAILABLE = -2147012889
Dim objSvrHTTP As XMLHTTP
Dim varProjectID, varCatID, strT As String
Set objSvrHTTP = New XMLHTTP
objSvrHTTP.Open "POST", "https://api.twilio.com/2010-04-01/Accounts/[YOUR_ACCOUNT_SID]/SMS/", False, "[YOUR_ACCOUNT_SID]", "[YOUR_AUTH_TOKEN]"
objSvrHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objSvrHTTP.send "message=" & Message & "&from=15555555555&to=" & Number
debug.print objSvrHTTP.responseText
‘If objSvrHTTP.status = 201 Then
‘txtXML = objSvrHTTP.responseText
‘MsgBox "Sent"
ElseIf objSvrHTTP.status = 400 Then
MsgBox "Failed with error# " & _
objSvrHTTP.status & _
" " & objSvrHTTP.statusText & vbCrLf & vbCrLf
ElseIf objSvrHTTP.status = 401 Then
MsgBox "Failed with error# " & objSvrHTTP.status & _
" " & objSvrHTTP.statusText & vbCrLf & vbCrLf
Else
MsgBox "Failed with error# " & objSvrHTTP.status & _
" " & objSvrHTTP.statusText
End If
Exit_Procedure:
On Error Resume Next
Set objSvrHTTP = Nothing
Exit Function
Error_Handler:
Select Case Err.Number
Case NOINTERNETAVAILABLE
MsgBox "Connection to the internet cannot be made or " & _
"Twilio website address is wrong"
Case Else
MsgBox "Error: " & Err.Number & "; Description: " & Err.Description
Resume Exit_Procedure
Resume
End Select
End Function
Run Code Online (Sandbox Code Playgroud)
德文 -
| 归档时间: |
|
| 查看次数: |
1117 次 |
| 最近记录: |