1
我想在我的网站www.bendali.co.za上添加Google +登录/注册按钮。我已经在这个代码:Google+登录/新人按钮
<!-- Place this asynchronous JavaScript just before your </body> tag -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
function signinCallback(authResult) {
if (authResult['access_token']) {
// Successfully authorized
// Hide the sign-in button now that the user is authorized, for example:
document.getElementById('signinButton').setAttribute('style', 'display: none');
} else if (authResult['error']) {
// There was an error.
// Possible error codes:
// "access_denied" - User denied access to your app
// "immediate_failed" - Could not automatically log in the user
// console.log('There was an error: ' + authResult['error']);
}
}
</script>
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="712370252357.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>
我从https://developers.google.com/+/web/signin/它采取。但是当我按下它时,它给了我对话框和一切,我接受它,按钮消失(所有这些都是正常的)。但它没有登录我或任何东西。我如何才能做到这一点?
在此先感谢。
你是否设法登录?我的意思是它是否告诉你,你已经登录? – DLJ
你是什么意思登录你?简短版本是您在成功登录后处于“已授权”状态。一旦您处于授权状态,您的应用程序就可以代表用户向Google进行API调用(获取用户的显示名称,列出可见的人员你的应用程序,等等)。 – class
要反映正在登录的用户,我们建议在登录回调中进行一次people.get API调用,以便您可以获取用户的姓名和个人资料图像来迎接他们。此时,您已经可以代表用户进行API调用了。要了解有关迎接用户的更多信息,请在今天下午2:30 PST收听我们的Google+开发人员现场节目。 (https://plus.google.com/events/cblr79ob8a042sjg64jgf93ka20) – Joanna