问一个 Google+ Login API 的回调函数问题。

2014-12-08 02:04:47 +08:00
 xiaolvmu
#求助

我是小白,对javascript一无所知......
在模板文件中添加如下代码(</body>之前)
  <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?onload=render';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(po, s);
  })();

  function render() {
    gapi.signin.render('customBtn', {
      //'callback': 'signinCallback',
      'clientid': 'http://876129027227-m4n8ghl8s6g8slbs2c48eh6o4fbdn4ff.apps.googleusercontent.com',
      'cookiepolicy': 'single_host_origin',
      'requestvisibleactions': 'http://schemas.google.com/AddActivity',
      'scope': 'https://www.googleapis.com/auth/plus.login'
    });
  }
  </script>
  <style type="text/css">
    #customBtn {
      display: inline-block;
      background: #cc3732 ;
      color: white;
      width: 175px;
      border-radius: 5px;
    }
    #customBtn :hover {
      background: #e74b37 ;
      cursor: hand;
    }
    span.label {
      font-weight: bold;
    }
    span.icon {
      background: url('/+/images/branding/btn_red_32.png') transparent 10px 50% no-repeat;
      display: inline-block;
      vertical-align: middle;
      width: 40px;
      height: 40px;
    }
    span.buttonText {
      display: inline-block;
      vertical-align: middle;
      padding-left: 40px;
      padding-right: 40px;
    }
  </style>
  <span class="label">Sign in with:</span>
  <div id="customBtn" class="customGPlusSignIn">
    <span class="icon"></span>
    <span class="buttonText">Google</span>
  </div>

这是添加Google登录按钮的。

想问一下,这个回调函数具体怎么编写呢?我没有接触过JavaScript,不懂怎么编写……
例如我想实现这样的效果:
用户授权,返回True,则跳转到注册页面,注册一个帐号,以后用户登录Google帐号就可以访问论坛(也就是绑定了Google帐号)
用户不授权,返回False,不过由于论坛只有注册才可以进入,按钮的页面正是登录界面,因此不用做任何反应。

这改怎么编写呢?
3147 次点击
所在节点    JavaScript
2 条回复
xiaolvmu
2014-12-08 02:05:31 +08:00
不好意思打了几个错别字
xiaolvmu
2014-12-08 02:14:24 +08:00
就是 Techllage.com ……网页底部的一个按钮

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/152244

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX