I created a Web App with Telegram and ReactJS, after that I enabled web app debug mod to see inspect options.
The only way I can get user information is:
var search = Telegram.WebApp.initData
var converted = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value) })
JSON.parse(converted.user)
Based on: https://core.telegram.org/bots/webapps#webappinitdata
But all the options the document calls are not there and there is another API which I need it is WebAppUser document, and again I can not access it.
My question is how can I be able to access it?
I see this JS file that Telegram says to add in our HTML, but I could not find the WebAppUser into it.
<script src="https://telegram.org/js/telegram-web-app.js"></script>
Short Video and demo: https://www.youtube.com/watch?v=rKFZd2rWk24
Thank you in advance.
I guess that WebAppUser section describes the properties of a user encoded in window.Telegram.WebApp.initData. So it should be safe to use validated and decoded information stored in window.Telegram.WebApp.initData to obtain a user data.
NB! It's my guess tho. I faced the same question in fact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With