2014-11-24 126 views
0

我在我的网站中使用Hello.js进行社交登录。我正在使用文档HERE中提供的标准代码。在Hello.js中验证访问令牌时出错

我的代码看起来是这样的

<script> 
    //user; 
    hello.on('auth.login', function (auth) { 
     // call user information, for the given network 
     hello(auth.network).api('/me').then(function (r) { 
      // Inject it into the container 
      //alert(r.name); 
      window.user = r.email; 
      window.im_name = r.name; 
      if (r.email) ajax1(); 

     }); 
    }); 

    hello.init({ 
     facebook: 'xxxxxxxxxxxxxxxxx', 
     google: 'xxxxxxxxxxxxxxxxxxxxxx5-q6xxxxxxxxxxxxxxxeusercontent.com', 
    }, { 
     redirect_uri: 'http://wstation.yzx.com/', 
     scope: 'email' 

    }); 

</script> 

HTML

<button class="btn-fb" onclick="hello('facebook').login()">Facebook</button> 
<button class="btn-google" onclick="hello('google').login()">Google</button> 

每一件事情是工作的罚款,我能够通过Facebook登录,然后发送证书到服务器登录用户。但是用户登录后。方法一直被一次又一次地调用。

我试图通过文档阅读,但是没有什么帮助了

UPDATE

我改变了代码弄成这个样子

function connect(x){ 
hello(x).api("/me").then(function(r){ 
     window.user = r.email; 
     window.im_name = r.name; 
     if (r.email) ajax1(); 
}, function(e){ 
    alert("Whoops! " + e.error.message); 
}); 
} 

HTML

<button class="btn-fb" onclick="connect('facebook')">Facebook</button> 
<button class="btn-google" onclick="connect('google')">Google</button> 

现在我得到错误

Whoops! Error validating access token: This may be because the user logged out or may be due to a system error. 

为警报

请帮助我,如果任何一个提前

回答

1

有同样的问题

感谢我得到它的工作希望这有助于有人否则具有相同的问题

<script> 

function connect(x){ 
hello(x).login().then(function(r){ 
    hello(r.network).api('/me').then(function(r){ 
     alert('Login'); 
     window.user = r.email; 
     window.im_name = r.name; 
     if (r.email) ajax1(); 
}, function(e){ 
    alert("Whoops! " + e.error.message); 
}); 
}); 

} 
hello.init({ 
    facebook: '2xxxxxxxxxxx4', 
    google: '3xxxxxxxxx5-qxxxxxxxxxxxxx6k1nunigepmsd3.apps.googleusercontent.com', 
    twitter: 'Yxxxxxxxxxxxw' 
}, { 
    redirect_uri: 'http://wstation.inmotico.com/', 
    scope: 'email' 

}); 


</script> 

谢谢& Regards

相关问题