【问题标题】:Google Apps and Retrieving Google Plus UserIDGoogle Apps 和检索 Google Plus 用户 ID
【发布时间】:2012-12-03 21:26:40
【问题描述】:

我们目前正在使用 Google Apps for Education 并启用了 Google Plus。我查看了许多 API 的 google 提议 https://developers.google.com/oauthplayground/ 并没有找到答案。

我希望能够在 Google 应用中查询用户并找出他们的 Google Plus ID。

Google+ 有自己的 API,我知道它处于教育测试阶段,所以可能只是他们没有添加到此列表中:https://developers.google.com/google-apps/ 在应用程序 API 下。

是否有可能通过调用组合从我们的用户电子邮件中获取 Google Plus 用户 ID?

提前致谢。

【问题讨论】:

    标签: google-plus


    【解决方案1】:

    这取决于你想要做什么,据我所知,你不能只在你的系统中根据他们的电子邮件查找某人的 Google+ id。

    但是,如果用户登录,您可以获得用户 ID,如 History 客户端启动器 Google+ history client-side flow 中所述。您无需编写时刻,而是阅读个人资料,然后可以检索他们的 Google+ 帐户的 ID。您将需要来自 Google APIs console 的客户端 ID,并启用 Google+ 服务,与客户端流程相同。获得此 ID 后,您可以创建 HTML 页面,该页面将使用 JavaScript 客户端获取 Google+ ID。

    以下代码显示了如何做到这一点:

    <html>
    <script src="https://apis.google.com/js/client.js"></script>
    <script src="https://apis.google.com/js/plusone.js"></script>
    <script type="text/javascript">
      function onSignInCallback(authResult){
        // Set the access token on the JavaScript API Client
        gapi.auth.setToken(authResult);
    
        var args = {
          'path': '/plus/v1moments/people/me',
          'method': 'GET',
          'callback': function(response) {
            var profile = response;
            console.log(profile);
            alert('id is ' + profile.id);
          }
        };
        gapi.client.request(args);
      }
    </script>
    
    <body>
      <!-- Render the sign-in button -->
      <g:plus action="connect"
              clientid="YOUR CLIENT ID"
              scope="https://www.googleapis.com/auth/plus.me"
              callback="onSignInCallback"></g:plus>
    </body>
    </html>
    

    当您运行上述代码时,它会弹出登录用户的 ID 作为警报。如果您尝试为非 Google(例如 GMail)帐户执行此操作,请使用您的域凭据登录以获取该 Google+ 帐户 ID。

    这是demo of this code

    【讨论】:

      【解决方案2】:

      我无法让 2012 年 12 月 4 日发布的答案正常工作,也许 google+ api 从那时起发生了变化,或者我只是错过了一些东西。但是,我确实使用 google 的快速入门示例获得了个人资料信息(包括原始发帖人想要的 id):

      https://developers.google.com/+/quickstart/javascript

      【讨论】:

        【解决方案3】:
        Follow these simple steps to find your Google Plus User ID:
        
        1) Login to your Google+ account.
        
        2) From the side menu click on the Profile icon
        
        3) In the address bar you will see your complete Google+ URL. It will look something like this:
        
        https://plus.google.com/100009709084787102522/posts
        
        4) Your Google Plus User ID is the long series of numbers. in this instance my Google+ ID is the following:
        
        100009709084787102522
        

        参考:http://www.jumpmobi.com/miscellaneous/what-is-my-google-google-plus-user-id/

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多