zoukankan      html  css  js  c++  java
  • google product

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset='utf-8' />
    </head>
    <body>
    <!--Add a button for the user to click to initiate auth sequence -->
    <button id="authorize-button" style="visibility: hidden">Authorize</button>
    <script type="text/javascript">
    // Enter a client ID for a web application from the Google Developer Console.
    // The provided clientId will only work if the sample is run directly from
    // https://google-api-javascript-client.googlecode.com/hg/samples/authSample.html
    // In your Developer Console project, add a JavaScript origin that corresponds to the domain
    // where you will be running the script.
    var clientId = '564722376202-in1jqjg3n5eb3e6n7kg2deps2qka1ijs.apps.googleusercontent.com';

    // Enter the API key from the Google Develoepr Console - to handle any unauthenticated
    // requests in the code.
    // The provided key works for this sample only when run from
    // https://google-api-javascript-client.googlecode.com/hg/samples/authSample.html
    // To use in your own application, replace this API key with your own.
    var apiKey = 'CjQaEhrHfbtQOjKreEQjrpRS';

    // To enter one or more authentication scopes, refer to the documentation for the API.
    var scopes = 'https://www.googleapis.com/auth/plus.me';

    // Use a button to handle authentication the first time.
    function handleClientLoad() {
    gapi.client.setApiKey(apiKey);
    window.setTimeout(checkAuth,1);
    }

    function checkAuth() {
    gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult);
    }


    function handleAuthResult(authResult) {
    var authorizeButton = document.getElementById('authorize-button');
    if (authResult && !authResult.error) {
    authorizeButton.style.visibility = 'hidden';
    makeApiCall();
    } else {
    authorizeButton.style.visibility = '';
    authorizeButton.onclick = handleAuthClick;
    }
    }

    function handleAuthClick(event) {
    gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
    return false;
    }

    // Load the API and make an API call. Display the results on the screen.
    function makeApiCall() {
    gapi.client.load('plus', 'v1', function() {
    var request = gapi.client.plus.people.get({
    'userId': '6099994'
    });
    request.execute(function(resp) {
    var heading = document.createElement('h4');
    var image = document.createElement('img');
    image.src = resp.image.url;
    heading.appendChild(image);
    heading.appendChild(document.createTextNode(resp.displayName));

    document.getElementById('content').appendChild(heading);
    });
    });
    }
    </script>
    <!-- <script type="text/javascript" src="authorSample.js"/> -->
    <!-- 例子:https://google-api-javascript-client.googlecode.com/hg/samples/authSample.html
    参照网页: https://developers.google.com/api-client-library/javascript/samples/samples

    maven版本:

    <dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.19.0</version>
    </dependency>
    <dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client-jackson2</artifactId>
    <version>1.19.0</version>
    </dependency>
    <dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-content</artifactId>
    <version>v2-rev33-1.19.1</version>
    </dependency>

    -->

    <script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
    <div id="content"></div>
    <p>Retrieves your profile name using the Google Plus API.</p>
    </body>
    </html>

  • 相关阅读:
    查看进程在CPU和内存占用的命令
    Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found
    awk命令过滤tomcat的访日日志中IP地址
    windows 2008R2系统程序运行提示无法定位程序输入点ucrtbase.terminate
    k8s中yaml文件pod的语法(转)
    etcd和redis的比较和日常使用场景
    从gitlab或者github采用git clone和download zip的区别
    记录一次mysql查询速度慢造成CPU使用率很高情况
    USG防火墙DHCP设置保留IP地址
    让docker容器开机启动
  • 原文地址:https://www.cnblogs.com/leo3689/p/4870358.html
Copyright © 2011-2022 走看看