如何使用twilio从MS Access发送消息? [英] How to send a message from MS Access using twilio?
本文介绍了如何使用twilio从MS Access发送消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做了很多研究,但没有发现任何东西.反正已经做到了吗?有什么例子吗?
I have done a lot of research but I have found nothing. Has anyways already done this? Any examples?
我想使用表单中的按钮发送消息,因此它应该调用vba代码并以相同的形式使用一些信息来发送消息.任何想法都很棒!
I want to send a message using a button in a form so it should call a vba code and use some information in the same form to send the message. Any ideas would be great!!
我正在使用Access 2010
I'm using Access 2010
推荐答案
此处是Twilio的传播者.
Twilio evangelist here.
简短的答案是,您需要使用VBA发布到Twilio REST API.
The short answer is you need to POST to the Twilio REST API using VBA.
以下是一些示例代码,展示了如何使用XMLHTTP进行操作:
Here is a bit of sample code that shows how to do this using 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
德文
这篇关于如何使用twilio从MS Access发送消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文