K
K
Kosyt Kosytov2018-07-20 16:22:13
JavaScript
Kosyt Kosytov, 2018-07-20 16:22:13

Why is it displayed that I am not an authorized user when I run the script, although I am logged in?

Good day! I'll try to explain the situation. I run a script on my site in order to find out the id in the VK of the user who has entered the site. And when I enter the site, it shows that I am not authorized, although I am authorized. , which has an application to this site, then it gives me an id. Tell me, how can I do it so that I can find out the id of any user who enters the site?
Here is the code:

<html>
<head>
    <script src="//vk.com/js/api/openapi.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="javascript">
window.onload = (function() {
    VK.init({
          apiId: 6637768 //id подключенного сайта
        });
    function authInfo(response) 
    {
      if (response.session)
      {
        document.getElementById('t').innerHTML = "Your ID: " + response.session.mid;
      } 
      else 
      {
        document.getElementById('t').innerHTML = 'Вы не авторизованы вконтакте.';
      }
    }
    VK.Auth.getLoginStatus(authInfo);
});
</script>
<div id='t'></div>

</body>
</html>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question