不要从电信网络应用程序中获取bot的响应

发布于 2025-01-22 03:07:48 字数 157 浏览 1 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦魇绽荼蘼 2025-01-29 03:07:48

根据senddata函数说明:

此方法仅适用于通过键盘按钮启动的Web应用程序

请参阅 https://core.telegram.org/bots/webapps#initializing-web-apps 有关更多信息。

因此,您需要将Web应用程序URL绑定到键盘按钮不是内联键盘按钮

不确定,但是如果您确实想使用内联键盘来调用您的Web应用程序,则需要在Web应用程序页面中实现自定义请求以将数据发送到后端。

According to sendData function description:

This method is only available for Web Apps launched via a Keyboard button

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.

我是男神闪亮亮 2025-01-29 03:07:48

此方法仅适用于通过键盘按钮启动的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.

断念 2025-01-29 03:07:48

我遇到了类似的问题,

该问题早些时候被诊断为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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文