我需要使用Twilio和Microsoft Access在短信中从我的电脑发送图像。
我能够通过Microsoft Access成功发送短信。但是,图像未被发送。我找到了一个名为" mediaURL"的参数。我想让mediaURL引用我电脑上的图像(" d:\ imagefolder")。
有没有人能够做到这一点。这是我发送短信的代码。
Dim MessageUrl As String
Dim FromURLEncode As String
Dim ToURLEncode As String
Dim imageURL As String
On Error GoTo Error_Handler
' setup the URL
MessageUrl = BASEURL & "/2010-04-01/Accounts/" & ACCOUNTSID & "/Messages"
imageURL = "d:\imagefolder\mypicture.png"
' setup the request and authorization
Dim http As MSXML2.XMLHTTP60
Set http = New MSXML2.XMLHTTP60
http.Open "POST", MessageUrl, False, ACCOUNTSID, AUTHTOKEN
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
Dim postData As String
postData = "From=" & fromNumber _
& "&To=" & toNumber _
& "&Body=" & body _
& "&MediaURL=" & imageURL
Debug.Print postData
' send the POST data
http.send postData
' optionally write out the response if you need to check if it worked
Debug.Print http.responseText
If http.Status = 201 Then
ElseIf http.Status = 400 Then
MsgBox "Failed with error# " & _
http.Status & _
" " & http.statusText & vbCrLf & vbCrLf & _
http.responseText
ElseIf http.Status = 401 Then
MsgBox "Failed with error# " & http.Status & _
" " & http.statusText & vbCrLf & vbCrLf
Else
MsgBox "Failed with error# " & http.Status & _
" " & http.statusText
End If
Exit_Procedure:
On Error Resume Next
' clean up
Set http = 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
答案 0 :(得分:2)
我终于可以使用MediaUrl发送包含图片的短信。我的代码正在使用MediaURL。它必须是“MediaUrl”。有一次,我想出来了,我已经能够发送带有图像的短信。
答案 1 :(得分:1)
Twilio开发者传道者在这里。
正如Thomas G在评论中回答的那样,您的问题是图像在您的计算机上。该网址需要提供给Twilio。
您需要将图像上传到服务器(您自己的或公共服务),然后使用该服务器。
查看the documentation on sending MMS with Twilio for more details。