简体   繁体   中英

Google Plus share and Sign in with Google plus disappeared

I have had a sign in with google plus on my site. It worked fine, and implemented according to the official tutorial( https://developers.google.com/+/web/signin/ ) as

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>

with the respective js client coded as an example on the official site A couple weeks ago it disappeared. At the same time, my share on google+ button also disappeared. This too, was working and coded according to the official site 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>

I'm not going into exact details here because my code was copied from the tutorials verbatim. Anyone see something obvious here? Was there a serious change in g+ api? The tutorials seem unchanged

Perhaps something happened to your plusone.js include? Make sure that this is on your page just before your closing body tag:

<!-- 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>

To test that it's loaded, open the JavaScript console and test for the existence of the gapi object:

gapi.plus.render

Secondly, it looks like your container (a span) doesn't have the opening tag. It should read as:

<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">

Finally, mind the way that you are setting the cookiepolicy. If it's configured incorrectly, the script will be blocked from loading. Try changing it to single_host_origin to see if it's not getting set correctly (it should typically be http://yoursite.com or https://yoursite.com the https and http makes a difference).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM