我想通过 http Telegram API 发送文件并尝试以下代码:
def send_media(self, chat_id, doc):
method = 'sendDocument'
params = {'chat_id': chat_id, 'document': doc}
resp = requests.post(self.api_url + method, params)
return resp
document = open('table.csv', 'rb')
doc = InputFile(document)
bot.send_media(last_chat_id, doc).json()
document.close()
Run Code Online (Sandbox Code Playgroud)
并根据要求出现这样的错误:
{'ok': False, 'error_code': 400, 'description': 'Bad Request: wrong URL host'}
Run Code Online (Sandbox Code Playgroud)
我应该怎么做才能发送文件?