DmitrMakeev commited on
Commit
c4f9bb1
·
verified ·
1 Parent(s): 19366da

Update user.html

Browse files
Files changed (1) hide show
  1. user.html +21 -15
user.html CHANGED
@@ -4,24 +4,30 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>VK Authorization</title>
7
- </head>
8
- <body>
9
- <div id="vk_api_transport"></div>
10
- <script type="text/javascript">
11
- window.vkAsyncInit = function() {
12
  VK.init({
13
  apiId: 52295022
14
  });
15
- };
16
-
17
- setTimeout(function() {
18
- var el = document.createElement("script");
19
- el.type = "text/javascript";
20
- el.src = "https://vk.com/js/api/openapi.js?169";
21
- el.async = true;
22
- document.getElementById("vk_api_transport").appendChild(el);
23
- }, 0);
24
- </script>
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  </body>
27
  </html>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>VK Authorization</title>
7
+ <script src="https://vk.com/js/api/openapi.js?169"></script>
8
+ <script>
 
 
 
9
  VK.init({
10
  apiId: 52295022
11
  });
12
+ </script>
13
+ </head>
14
+ <body>
15
+ <div id="vk_auth_button"></div>
16
+ <script>
17
+ VK.UI.button("vk_auth_button");
 
 
 
 
18
 
19
+ document.getElementById("vk_auth_button").addEventListener("click", function() {
20
+ VK.Auth.login(function(response) {
21
+ if (response.session) {
22
+ /* Пользователь успешно авторизовался */
23
+ console.log("User ID:", response.session.user.id);
24
+ console.log("User Info:", response.session.user);
25
+ } else {
26
+ /* Пользователь нажал кнопку Отмена в окне авторизации */
27
+ console.log("Authorization canceled");
28
+ }
29
+ }, 4); // Запрос прав на доступ к фотографиям (пример)
30
+ });
31
+ </script>
32
  </body>
33
  </html>