DmitrMakeev commited on
Commit
c1353c8
·
verified ·
1 Parent(s): ce9de36

Update pages.html

Browse files
Files changed (1) hide show
  1. pages.html +0 -99
pages.html CHANGED
@@ -935,105 +935,6 @@ z-index: 1000; /* Убедитесь, что кнопка находится п
935
 
936
 
937
 
938
- <div class="mod_vk" id="vkid-container"></div>
939
-
940
-
941
- <script src="https://unpkg.com/@vkid/sdk@<3.0.0/dist-sdk/umd/index.js"></script>
942
- <script type="text/javascript">
943
- if ("VKIDSDK" in window) {
944
- const VKID = window.VKIDSDK;
945
-
946
- VKID.Config.init({
947
- "app": 52295022,
948
- "redirectUrl": "https://diamonik7777-up-fail.hf.space/monitor",
949
- "source": VKID.ConfigSource.LOWCODE,
950
- });
951
-
952
- const oneTap = new VKID.OneTap();
953
-
954
- oneTap.render({
955
- "container": document.getElementById('vkid-container'), // Используем правильный контейнер
956
- "showAlternativeLogin": true,
957
- "styles": {
958
- "width": 360
959
- }
960
- })
961
- .on(VKID.WidgetEvents.ERROR, vkidOnError)
962
- .on(VKID.OneTapInternalEvents.LOGIN_SUCCESS, function (payload) {
963
- const code = payload.code;
964
- const deviceId = payload.device_id;
965
-
966
- VKID.Auth.exchangeCode(code, deviceId)
967
- .then(vkidOnSuccess)
968
- .catch(vkidOnError);
969
- });
970
- }
971
-
972
- function vkidOnSuccess(data) {
973
- // Обработка полученного результата
974
- console.log('VKID Success:', data);
975
-
976
- // Сохранение токена в localStorage
977
- localStorage.setItem('vkidAccessToken', data.access_token);
978
-
979
- // Получение информации о пользователе
980
- getVkUserInfo(data.access_token);
981
-
982
- // Остановка редиректа
983
- // Просто не выполняйте window.location.href
984
- }
985
-
986
- function vkidOnError(error) {
987
- console.error('VKID Error:', error);
988
- // Обработка ошибки
989
- }
990
-
991
- function getVkUserInfo(token) {
992
- // Запрос к API ВКонтакте для получения информации о пользователе
993
- fetch('https://api.vk.com/method/users.get?v=5.131&access_token=' + token)
994
- .then(response => {
995
- if (!response.ok) {
996
- throw new Error('Network response was not ok ' + response.statusText);
997
- }
998
- return response.json();
999
- })
1000
- .then(data => {
1001
- if (data.response && data.response.length > 0) {
1002
- const userInfo = data.response[0];
1003
- console.log('User ID:', userInfo.id);
1004
- sendRequestWithUserId(userInfo.id); // Отправить запрос с ID пользователя
1005
- } else {
1006
- console.error('Failed to get user info:', data);
1007
- }
1008
- })
1009
- .catch(error => {
1010
- console.error('Error getting user info:', error);
1011
- });
1012
- }
1013
-
1014
- function sendRequestWithUserId(userId) {
1015
- // Пример отправки запроса с ID пользователя
1016
- fetch('https://your-api-endpoint.com/some-resource', {
1017
- method: 'POST',
1018
- headers: {
1019
- 'Content-Type': 'application/json'
1020
- },
1021
- body: JSON.stringify({ userId: userId })
1022
- })
1023
- .then(response => {
1024
- if (!response.ok) {
1025
- throw new Error('Network response was not ok ' + response.statusText);
1026
- }
1027
- return response.json();
1028
- })
1029
- .then(data => {
1030
- console.log('Response from API:', data);
1031
- })
1032
- .catch(error => {
1033
- console.error('Error sending request:', error);
1034
- });
1035
- }
1036
- </script>
1037
 
1038
 
1039
 
 
935
 
936
 
937
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
938
 
939
 
940