我已在我的网站上使用 google plus 登录。效果很好,按照官方教程(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 有重大变化吗?教程似乎没有变化
最佳答案
也许你的 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.com 或 https://yoursite.com,https 和 http 有所不同)。
关于javascript - Google Plus 共享和使用 Google Plus 登录消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17242293/