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