问题
I'm trying to simulate how to send a message to a bot from a url but it doesn't work.
I try to explain (note: all the ids and tokens are not real, they are only to explain !!) ..
I've built a first bot from BotFather named Bot1Bot and then, form url if I try
https://api.telegram.org/bot532708503:BBGn5ORfLppFu05-bi088F4SyKAiITfXH1w/getme
the response is
{"ok":true,"result":{"id":532708503,"is_bot":true,"first_name":"Bot1Bot","username":"Bot1Bot"}}
Then I've built a second bot from BotFather named Bot2Bot and then, form url if I try
https://api.telegram.org/bot632805599:XXGn7ORfLppFu06-bd099F4SyKAiITfXH1y/getme
the response is
{"ok":true,"result":{"id":632805599,"is_bot":true,"first_name":"Bot2Bot","username":"Bot2Bot"}}
Now I'd like to simulate how to send a message from Bot1Bot to Bot2Bot and so I've tried this request ...
https://api.telegram.org/bot532708503:BBGn5ORfLppFu05-bi088F4SyKAiITfXH1w/sendmessage?chat_id=632805599&text=xxxxxxxx
or this request ...
https://api.telegram.org/bot632805599:XXGn7ORfLppFu06-bd099F4SyKAiITfXH1y/sendmessage?chat_id=532708503&text=xxxxxxxx
.. but the response is
{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}
Where am I doing wrong?
Are there some settings in my two bots that I've to set?
My final goal is to do the same in a PHP code ...
回答1:
actually, telegram bot to bot communication is not possible. chat_id used in URL is chat_id of a person that subscribed to your bot and by this chat_id and your Bot token, you can send a message to a subscribed user.
Even if you add them both to one group chats so that @bot1 will send /start@bot2 and @bot2 will send /start@bot1, they won't get these messages.
来源:https://stackoverflow.com/questions/48348627/simulate-sending-a-message-to-a-bot-from-url