Problem using webwrite to send image in telegram API
古いコメントを表示
Hey everyone,
i need to send some messages with image throuout the REST API of telegram.
here is my code for text sending, and it works correctly.
token = '1769425585:AAGPOrIaLTKYr9THQDkehlwrjdxfiJxHNuw';
requestType = 'sendMessage?';
id = 54573663;
url = ['https://api.telegram.org/bot' token '/' requestType 'chat_id=' num2str(id) '&text=' msg];
options = weboptions('ContentType','json','UserAgent','Abolfazl','RequestMethod','post','ArrayFormat','json');
resp
onse = webwrite(url,options);
but the problem is with regard to sending photos
here is the python code for photo sending.
the code uses a dictionary for the photo section but I don't know how to convert it to the Matlab code.
here is the python code,
import requests
import json
bot_token = 'BOT TOKEN'
chat_id = "CHAT ID"
file = r"C:\Users\name\OneDrive\Desktop\Capture.PNG"
files = {
'photo': open(file, 'rb')
}
message = ('https://api.telegram.org/bot'+ bot_token + '/sendPhoto?chat_id='
+ chat_id)
send = requests.post(message, files = files)
I will appreciate your help.
kind regards,
Abolfazl Nejatian
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!