简体   繁体   English

如何将请求json字符串发送到电报并仅通过键盘按钮json字符串接收消息?

[英]How to send request json string to telegram and receive message by keyboard button only json string?

I am programming in telegram bot , and I am using only JSON string for sending and receiving data from/to telegram server. 我正在电报bot中编程,并且我仅使用JSON字符串从电报服务器发送数据或从电报服务器接收数据。

For example I want to send JSON this like: 例如,我想像这样发送JSON:

https://api.telegram.org/bot347803164:AAEg**************KweblvdP25sYIqpeQ/sendmessage?chat_id=*********&text=**testbtn**&replymarkup=[text=test,call_back_data:1,url:http:www.google.com]]

but the response after sending my request is only text message: 但发送我的请求后的响应仅为文本消息:

testbtn

and does not have button or replykeyboard?! 而且没有按钮或答复键盘?

I want to send JSON request and receive message by key board button. 我想通过键盘按钮发送JSON请求并接收消息。
Help me please. 请帮帮我。

1.you have some typos in your request: such as "reply_markup", "call_back_data", or even your google url! 1.您的请求中有一些错别字:例如“ reply_markup”,“ call_back_data”,甚至您的Google网址!

  1. you can only have one of the "callback_data" or "url" for each of your buttons. 您只能为每个按钮使用“ callback_data”或“ url”之一。

  2. the right format of inlinekeyboards are as follow. 内联键盘的正确格式如下。

     https://api.telegram.org/bot347803164:AAEg**************KweblvdP25sYIqpeQ/sendmessage?chat_id=*********&text=testbtn&reply_markup={"inline_keyboard": [[{"text": "text1","callback_data": "cb1"}],[{"text": "text2","callback_data": "cb2"}, {"text": "text3","callback_data": "cb3"}, {"text": "text4","url": "http://www.google.com"}]]} 
  3. if you want to send simple keyboards(not inline transparent keyboards) use the below format: 如果要发送简单的键盘(非嵌入式透明键盘),请使用以下格式:

     https://api.telegram.org/bot347803164:AAEg**************KweblvdP25sYIqpeQ/sendmessage?chat_id=*********&text=testbtn&reply_markup={"keyboard": [[{"text" :"text1"}],[{"text" :"text2"}]]} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM