Telegram Web Apps API와의 일반 -JS 상호 작용을 포함하는 HTML-File 예제. 라이브 데모 : 봇을 부착하십시오.
웹 앱은 어딘가에 호스팅되어야합니다. GitHub 저장소에서 호스팅하는 것은 빠르고 무료 방법입니다.
https://{github-username}.github.io/{repository-name}/{location-inside-repository}
에서 사용할 수 있습니다. 이 경우 : https://revenkroz.github.io/telegram-web-app-bot-example/index.html
사용자에게 특수 메뉴 버튼을 표시합니다 (메시지 입력 필드 근처) :
Bot Settings
- Menu Button
- Specify..
/ Edit menu button URL
https://revenkroz.github.io/telegram-web-app-bot-example/index.html
) 두 번째 방법은 웹 앱에 URL에 Field web_app
이 포함 된 데이터가 포함 된 버튼을 보내는 것입니다.
{
"text" : " Test web_app " ,
"web_app" : {
"url" : " https://revenkroz.github.io/telegram-web-app-bot-example/index.html "
}
}
웹 앱을 Telegram 클라이언트에 연결하려면이 코드 (추가 정보)를 사용하여 스크립트 telegram-web-app.js
다른 스크립트 앞에 <head>
태그에 넣습니다.
< script src =" https://telegram.org/js/telegram-web-app.js " > </ script >
스크립트가 연결되면 window.Telegram.WebApp
객체를 사용할 수 있습니다.