如何使用 Excel VBA 将桌面照片发送到电报
How to send a desktop photo to telegram using Excel VBA
您好,
我需要支持来使用示例或确切代码来执行此操作,因为我迷路了并且对发送
一无所知
Function VBA2Telegram(token As String, ChatID As String)
Dim msg1 As String, PostMsgStr As String, PhotoPath As String,sUrl As String
Dim oHttp As Object, sHTML As String, PostPhotoStr As String, strPostData As String
msg1 = "Hello there"
PhotoPath = "C:23.jpg"
PostMsgStr = "https://api.telegram.org/bot" & token & "/sendMessage?chat_id=" & ChatID & "&text=" & msg1
PostPhotoStr = "https://api.telegram.org/bot" & token & "/sendPhoto?chat_id=" & ChatID & "&photo=" & PhotoPath
Set oHttp = CreateObject("MSXML2.XMLHTTP")
oHttp.Open "POST", PostMsgStr, False
oHttp.Send
'Here,, how to set the code to do the job of sending local photo to telegram!
oHttp.Open "POST", PostPhotoStr, False
oHttp.Send
sHTML = oHttp.ResponseText
Debug.Print sHTML
End Function
要上传您计算机中的照片,您不能使用 GET 方法来请求您的文件路径,而您应该 POST 一个 multipart/form-data 时尚的表单,其中包含文件内容:见。
您可以在vba中搜索如何使用multipart/form-data。这 link or 也可能对您有所帮助。
您好, 我需要支持来使用示例或确切代码来执行此操作,因为我迷路了并且对发送
一无所知Function VBA2Telegram(token As String, ChatID As String)
Dim msg1 As String, PostMsgStr As String, PhotoPath As String,sUrl As String
Dim oHttp As Object, sHTML As String, PostPhotoStr As String, strPostData As String
msg1 = "Hello there"
PhotoPath = "C:23.jpg"
PostMsgStr = "https://api.telegram.org/bot" & token & "/sendMessage?chat_id=" & ChatID & "&text=" & msg1
PostPhotoStr = "https://api.telegram.org/bot" & token & "/sendPhoto?chat_id=" & ChatID & "&photo=" & PhotoPath
Set oHttp = CreateObject("MSXML2.XMLHTTP")
oHttp.Open "POST", PostMsgStr, False
oHttp.Send
'Here,, how to set the code to do the job of sending local photo to telegram!
oHttp.Open "POST", PostPhotoStr, False
oHttp.Send
sHTML = oHttp.ResponseText
Debug.Print sHTML
End Function
要上传您计算机中的照片,您不能使用 GET 方法来请求您的文件路径,而您应该 POST 一个 multipart/form-data 时尚的表单,其中包含文件内容:见
您可以在vba中搜索如何使用multipart/form-data。这 link or