inlinekeyboard to open web app..it will ok
Now how can i get user information in requested web address...is telegram sending special update to that url or sending data with user click on post or some thing??
Imagine you opening example.com web address in web app by clicking on web app
Inline keyboard
Is this address recive some special user data on header or body???
initData
initData
How??
put it in top of <head> <script src="https://telegram.org/js/telegram-web-app.js"></script> then check ... window.Telegram.WebApp.initData
initData it's a method?
This isn't show any thing when i try to open web app bot rest of code is runing...
You can not access to console when launching web app
Telegram uses WebView to show your WebApp It request a WebView and inside that WebView there is an iframe which injects UserData to that iframe (based on the user information on that client) And inside that iframe, is our website, which uses telegram-web-app.js file This file's purpose is it waits for data from its parent (since it knows that our page lives inside in iframe), then it receives data and makes it accessible through initData method It also makes some of its methods accessible through window object, making it seem magical (: And based on information that it gets from its parent iframe, it sets some CSS and JS variables for user Theme, nothing is magical The initData is the data that you have to send it to your backend and try to encrypt it with your bot token and see if the hashes match If they do, then you have received a valid initData from telegram client, if not, then it's not from telegram clients
Ok thanks both
Обсуждают сегодня