2013-06-21 49 views
1

我已登錄谷歌加在我的網站上。它工作得很好,並實現了根據官方教程(https://developers.google.com/+/web/signin/)作爲谷歌加分享和使用谷歌加號消失

class="g-signin" 
data-callback="onSignInCallback" 
data-clientid=<my id> 
data-approvalprompt="force" 
data-width="wide" 
data-cookiepolicy="http://<?php echo $c_site; ?>.com" 
data-requestvisibleactions="http://schemas.google.com/AddActivity" 
data-scope="https://www.googleapis.com/auth/plus.login  https://www.googleapis.com/auth/userinfo.email"> 
</span> 

與各自的js客戶編碼作爲一個例子在官方網站上 幾個星期前就消失了。同時,我在Google +按鈕上的分享也消失了。這也是,按照官方網站 https://developers.google.com/+/web/share/

   <div class="g-plus" data-action="share" data-annotation="none" displayText="<?php echo $someBullshit;?>" data-href="<?php echo $url;?>" ></div> 

,因爲我的代碼是從教程逐字複製我不打算到具體的細節在這裏工作和編碼。有人在這裏看到明顯的東西? g + api有沒有發生重大變化?教程似乎沒有變化

回答

1

也許你的plusone.js中包含了什麼?只是你的結束標記之前確保這是您的網頁上:

<!-- 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); 
})(); 
</script> 

爲了測試它的加載,打開JavaScript控制檯,並測試了GAPI對象的存在:

gapi.plus.render 

其次,它看起來像你的容器(一個範圍)沒有開始標籤。它應該閱讀:

<span class="g-signin" 
    data-callback="onSignInCallback" 
    data-clientid=<my id> 
    data-approvalprompt="force" 
    data-width="wide" 
    data-cookiepolicy="single_host_origin" 
    data-requestvisibleactions="http://schemas.google.com/AddActivity" 
    data-scope="https://www.googleapis.com/auth/plus.login  https://www.googleapis.com/auth/userinfo.email"> 

最後,記住您是在設定的CookiePolicy的方式。如果配置不正確,腳本將被阻止加載。嘗試將其更改爲single_host_origin以查看它是否沒有正確設置(它通常應該是http://yoursite.comhttps://yoursite.com,而https和http有所不同)。