0
var isAuth = false;
   function __authInfo(response) {
      if (response.session)
        isAuth = true;
      else 
        isAuth = false;
    }

    function __wallPost(){
        if(isAuth){
                VK.Api.call('wall.post', {message: 'test api', attachment: 'photo61900_293400694'}, function(r) {
                  if(r.response) {
                    alert('Сообщение добавлено');
                  }
                });
            }else{
                VK.Auth.login(__authInfo);
                __wallPost();
        }
    }
    document.getElementById('QwallPost').addEventListener('click', __wallPost, false);

__wallPost(); зацикливается, isAuth не меняет свое значение на true. Что делаю не так?

1 ответ 1

2

Замените VK.Auth.login(__authInfo); на

Vl.Auth.login(function(response){ __authInfo(response); __wallPost(); })

Правда, если залогиниться не удастся, форма всплывет вновь.

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.