英文:
send txt file in telegam via request website to telegram bot
问题
我想使用一个请求网站(https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx)和Telegram中的一个机器人发送文件。
例如,以下代码用于向机器人发送消息:
TEXT = input('请输入您的文本:')
url = (f'https://api.telegram.org/bot{apiToken}/sendmessage?chat_id={chatID}&text={TEXT}')
payload = {"UrlBox": url,
"AgentList": "Mozilla Firefox",
"VersionsList": "HTTP/1.1",
"MethodList": "POST"
}
req = requests.post("https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx" , data=payload)
print(req)
但我不知道如何使用这个网站发送文件。我之所以要这样做,是因为Telegram在我们国家无法正常使用,我们必须使用VPN或第三方网站。
我尝试过ChatGPT并查阅Telegram文档。我找到了一个名叫m7.arman的人(用户名:14770721),他回答了我的问题,但答案不正确,没有帮助。虽然这个答案有效,但它无法通过https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx发送文件。
英文:
I want to send a file using a request website(https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx) and a bot in telegram
for example this code is for sending a massage in roobt :
TEXT = input('please enter your text : ')
url = (f'https://api.telegram.org/bot{apiToken}/sendmessage?chat_id={chatID}&text={TEXT}')
payload = {"UrlBox":url,
"AgentList":"Mozilla Firefox",
"VersionsList":"HTTP/1.1",
"MethodList":"POST"
}
req = requests.post("https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx" , data=payload)
print(req)
but i don't know how to send files with this website
i want to do this all because telegram is not working in our country and we have to use a vpn or third-party websites.
I tried chatgpt and searching in telegram documents
I found some guy named m7.arman (user:14770721) answered my question worng and it wasn't helpful
it is true and it works but it won't send file via https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx
答案1
得分: 0
无法使用该网站发送文件。
使用sendDocument
方法发送文件需要将文件传递为multipart/form-data,但是httpdebugger.com不提供将文件作为表单数据传递给POST请求的选项。
您需要使用代理或其他网站来向Telegram发送文件。
英文:
It's simply not possible to send files using that website.
Sending files using the sendDocument
method requires passing the file as multipart/form-data, however, httpdebugger.com does not provide an optie to pass files as form-data for a POST request.
You'll need a proxy or an other website to send files to Telegram.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论