Hallo zusammen,
ich bin gerade bei einem Projekt mir mein eigenes SmartHome aufzubauen. Aktuell auf Basis VBA (steinigt mich nicht, das kann ich relativ gut. Später kommt evtl. was anderes)
Teil davon ist ein TelegramBot der mir von außerhalb die Kommunikation mit dem SmartHome ermöglicht. Der Bot Funktioniert soweit gut und läuft mittlerweile eigentlich rund.
Mein Problem jetzt:
Ich möchte einen Screenshot des Rechners, auf dem das Programm läuft, verschicken. Wie ich einen Screenshot speicher, hab ich mittlerweile raus. Ich hänge gerade an dem Code um das ganze bei Telegram hochzuladen und zu versenden.
Die Doku sagt folgendes:
bzw.
Bei mir scheiterts jetzt am "multipart/form-data". Ich habe keine Ahnung, wie ich damit ein Bild zu Telegram schicken soll.
Kann mir da jemand auf die Sprünge helfen?
Die normalen Nachrichten versende ich zB. so:
ich bin gerade bei einem Projekt mir mein eigenes SmartHome aufzubauen. Aktuell auf Basis VBA (steinigt mich nicht, das kann ich relativ gut. Später kommt evtl. was anderes)
Teil davon ist ein TelegramBot der mir von außerhalb die Kommunikation mit dem SmartHome ermöglicht. Der Bot Funktioniert soweit gut und läuft mittlerweile eigentlich rund.
Mein Problem jetzt:
Ich möchte einen Screenshot des Rechners, auf dem das Programm läuft, verschicken. Wie ich einen Screenshot speicher, hab ich mittlerweile raus. Ich hänge gerade an dem Code um das ganze bei Telegram hochzuladen und zu versenden.
Die Doku sagt folgendes:
Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. More info on Sending Files »
bzw.
Sending files
There are three ways to send files (photos, stickers, audio, media, etc.):
- If the file is already stored somewhere on the Telegram servers, you don't need to reupload it: each file object has a file_id field, simply pass this file_id as a parameter instead of uploading. There are no limits for files sent this way.
- Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file. 5 MB max size for photos and 20 MB max for other types of content.
- Post the file using multipart/form-data in the usual way that files are uploaded via the browser. 10 MB max size for photos, 50 MB for other files.
Bei mir scheiterts jetzt am "multipart/form-data". Ich habe keine Ahnung, wie ich damit ein Bild zu Telegram schicken soll.
Kann mir da jemand auf die Sprünge helfen?
Die normalen Nachrichten versende ich zB. so:
Code:
Private Function mfHTTP_POST()
mfHTTP_POST = vbNullString
With CreateObject("MSXML2.XMLHTTP")
pstrURL = "https://api.telegram.org/bot0000000000/sendMessage?"
pstrPostData = "{""chat_id"": ""0000000000"", ""text"": ""Beispieltext""}"
.Open "POST", pstrURL, False
.setRequestHeader "Content-Type", "application/json"
.Send (pstrPostData)
mfHTTP_POST = .ResponseText
End With
End Function