不要从电信网络应用程序中获取bot的响应
我使用Web_App字段创建内联键盘,并打开Web应用程序。 但是如何从中获取数据? window.telegram.webapp.senddata('data') - Web应用中的此方法不会引发错误,但是在服务器上的侦听器中,该方法没有任何内容,甚至方法getupdates也没有看到任何东西。
I create inline keyboard with web_app field, and it open Web app.
But how get data from it?
window.Telegram.WebApp.sendData('data') - this method in web app does not throw an error, but in listeners on server don't get anything, even method getUpdates doesn't see anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据senddata函数说明:
请参阅 https://core.telegram.org/bots/webapps#initializing-web-apps 有关更多信息。
因此,您需要将Web应用程序URL绑定到键盘按钮不是内联键盘按钮。
不确定,但是如果您确实想使用内联键盘来调用您的Web应用程序,则需要在Web应用程序页面中实现自定义请求以将数据发送到后端。
According to sendData function description:
See https://core.telegram.org/bots/webapps#initializing-web-apps for more.
So you need to bind your web app url to keyboard button not inline keyboard button.
Don't sure, but if you really want to use inline keyboard to call your web app you need to implement custom requests in web app page to send data to your backend.
此方法仅适用于通过键盘按钮启动的Web应用程序。
但是,您可以通过指定的方法(根据您的应用程序逻辑)和用户ID来向后端发送常规的HTTP请求,从而使您的后端向后端发送一个常见的HTTP请求,从而进行解决方法。
This method is only available for Web Apps launched via a Keyboard button.
However, you can make a workaround by sending in a background a usual http request to your backend with a specified method (according to your apps logics) and a user id.
我遇到了类似的问题,
该问题早些时候被诊断为HTTP触发器。这是错误的。问题是该按钮不会通过正确的URL或可能根本没有传递。
按钮对象正确触发它。
buggy代码是此
replo_markup = inlineKeyboard.from_button(
键盘按钮(
text =“单击此处开始开始!”,
web_app = webappinfo(url =“ *******************)
),
工作代码。
Reply_markup = inlineKeyboardMarkup([[
[InlineKeyBoardButton(text ='profile',web_app = webappinfo(“ *******************)),
希望这对大家有帮助。
你可以在这里找到我。
https://t.me/me_roving
I had similar issues
The issue earlier was diagnosed as an Http trigger. Which was wrong. The issue is that the button does not pass the correct url or may be is not passing it at all.
The button object triggers it correctly.
Buggy Code is this
reply_markup=inlineKeyboard.from_button(
KeyboardButton(
text="Click Here to get Started!",
web_app=WebAppInfo(url="*********************)
) ),
Working code is this.
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton(text='Profile', web_app=WebAppInfo("***********))],
Hope this helps you guys.
You can find me here.
https://t.me/me_roving