-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
84 lines (77 loc) · 2.62 KB
/
index.html
File metadata and controls
84 lines (77 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Telegram Login Demo</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: #f4f4f9;
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
text-align: center;
}
.container {
background: white;
padding: 40px;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
max-width: 500px;
width: 90%;
}
h1 {
color: #2aabee; /* Telegram Blue */
}
p {
line-height: 1.6;
}
#user-info {
margin-top: 20px;
text-align: left;
background-color: #f0f0f0;
padding: 15px;
border-radius: 8px;
word-wrap: break-word;
}
pre {
white-space: pre-wrap;
}
</style>
</head>
<body>
<div class="container">
<h1>Telegram Login Widget Demo 🚀</h1>
<p>Click the button below. You will be prompted to authorize this website through your Telegram account. No server backend is needed for this demo; all data is handled directly by your browser.</p>
<div id="telegram-login-button">
<script async src="https://telegram.org/js/telegram-widget.js?22"
data-telegram-login="lettelegramdotheworkBot"
data-size="large"
data-onauth="onTelegramAuth(user)"
data-request-access="write"></script>
</div>
<div id="user-info" style="display:none;">
<h2>✅ Welcome!</h2>
<p>Here is the user object your browser received from Telegram:</p>
<pre id="user-data"></pre>
</div>
</div>
<script type="text/javascript">
// This function is called by the Telegram widget after successful authorization.
function onTelegramAuth(user) {
// Hide the login button
document.getElementById('telegram-login-button').style.display = 'none';
// Show the user info container
const userInfoDiv = document.getElementById('user-info');
userInfoDiv.style.display = 'block';
// Display the user data as a formatted JSON string
const userDataPre = document.getElementById('user-data');
userDataPre.textContent = JSON.stringify(user, null, 2);
}
</script>
</body>
</html>