N
N
netz-sanya2014-04-25 07:51:33
In contact with
netz-sanya, 2014-04-25 07:51:33

How to safely find out the id of the vk user who logged into the application?

Actually, the question is this - how to safely find out the id of the user who logged into the iframe application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2014-05-13
@PeterLozhkin

<script src="//vk.com/js/api/xd_connection.js?2"  type="text/javascript">
<script type="text/javascript" charset="cp1251" >
<code lang="javascript">
    window.onload = (function() {   // когда загрузится вся страница
        VK.init(function() {    // инициализируем Vk API

            // узнаём flashVars, переданные приложению GET запросом.
           // Сохраняем их в переменную flashVars
            var parts=document.location.search.substr(1).split("&");
            var flashVars={}, curr;
            for (i=0; i<parts.length; i++) {
                curr = parts[i].split('=');
                // записываем в массив flashVars значения.
               // Например: flashVars['viewer_id'] = 1;
                flashVars[curr[0]] = curr[1];
            }

            // получаем viewer_id из полученных переменных
            var viewer_id = flashVars['viewer_id'];
             
        });
    });
</code>
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question