久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <i id='rkdpf'><tr id='rkdpf'><dt id='rkdpf'><q id='rkdpf'><span id='rkdpf'><b id='rkdpf'><form id='rkdpf'><ins id='rkdpf'></ins><ul id='rkdpf'></ul><sub id='rkdpf'></sub></form><legend id='rkdpf'></legend><bdo id='rkdpf'><pre id='rkdpf'><center id='rkdpf'></center></pre></bdo></b><th id='rkdpf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rkdpf'><tfoot id='rkdpf'></tfoot><dl id='rkdpf'><fieldset id='rkdpf'></fieldset></dl></div>
        <legend id='rkdpf'><style id='rkdpf'><dir id='rkdpf'><q id='rkdpf'></q></dir></style></legend>
      1. <tfoot id='rkdpf'></tfoot>

        <small id='rkdpf'></small><noframes id='rkdpf'>

        • <bdo id='rkdpf'></bdo><ul id='rkdpf'></ul>

        從 Google OAuth 2.0 PHP API 獲取用戶信息

        Get Userinfo from Google OAuth 2.0 PHP API(從 Google OAuth 2.0 PHP API 獲取用戶信息)
          <tbody id='gPvWs'></tbody>

        • <i id='gPvWs'><tr id='gPvWs'><dt id='gPvWs'><q id='gPvWs'><span id='gPvWs'><b id='gPvWs'><form id='gPvWs'><ins id='gPvWs'></ins><ul id='gPvWs'></ul><sub id='gPvWs'></sub></form><legend id='gPvWs'></legend><bdo id='gPvWs'><pre id='gPvWs'><center id='gPvWs'></center></pre></bdo></b><th id='gPvWs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gPvWs'><tfoot id='gPvWs'></tfoot><dl id='gPvWs'><fieldset id='gPvWs'></fieldset></dl></div>

          <small id='gPvWs'></small><noframes id='gPvWs'>

        • <legend id='gPvWs'><style id='gPvWs'><dir id='gPvWs'><q id='gPvWs'></q></dir></style></legend>

        • <tfoot id='gPvWs'></tfoot>

            <bdo id='gPvWs'></bdo><ul id='gPvWs'></ul>

                  本文介紹了從 Google OAuth 2.0 PHP API 獲取用戶信息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在嘗試使用 Google Oauth API 來獲取用戶信息.它非常適合 Google Plus API,但我正在嘗試創(chuàng)建備份,以防用戶沒有 google plus 帳戶.身份驗證過程是正確的,我什至獲得了 $userinfo 對象,但我究竟如何訪問這些屬性.我試過 $userinfo->get() 但它只返回用戶的 id.

                  我做錯了嗎?這是我正在使用的代碼...

                  require_once '../../src/Google_Client.php';require_once '../../src/contrib/Google_Oauth2Service.php';session_start();$client = new Google_Client();$client->setApplicationName("Google+ PHP Starter Application");//訪問 https://code.google.com/apis/console 生成您的//oauth2_client_id、oauth2_client_secret,并注冊您的 oauth2_redirect_uri.$client->setClientId('*********************');$client->setClientSecret('****************');$client->setRedirectUri('***************');$client->setDeveloperKey('**************');$plus = new Google_Oauth2Service($client);如果(isset($_REQUEST ['注銷'])){未設(shè)置($_SESSION['access_token']);}如果(isset($_GET['代碼'])){$client->authenticate($_GET['code']);$_SESSION['access_token'] = $client->getAccessToken();header('位置:http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);}如果(isset($_SESSION['access_token'])){$client->setAccessToken($_SESSION['access_token']);}if ($client->getAccessToken()){$userinfo = $plus->userinfo;print_r($userinfo->get());} 別的{$authUrl = $client->createAuthUrl();}?><!doctype html><頭><meta charset="utf-8"><link rel='stylesheet' href='style.css'/><身體><header><h1>Google+ 示例應(yīng)用</h1></header><div class="box"><?php if(isset($personMarkup)): ?><div class="me"><?php print $personMarkup ?></div><?php endif ?><?php如果(isset($authUrl)){print "<a class='login' href='$authUrl'>連接我!</a>";} 別的 {打印 "<a class='logout' href='?logout'>Logout</a>";}?>

                  謝謝...

                  **編輯***缺少范圍--已添加

                   $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'));

                  現(xiàn)在工作...

                  解決方案

                  缺少作用域

                  $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'));

                  現(xiàn)在就像一個魅力!

                  I am trying to use Google Oauth API to get userinfo. It works perfectly for Google Plus API but I am trying to create a backup in case the user doesn't have google plus account. The authentication process is correct and I even get the $userinfo object but how exactly do I access the properties. I tried $userinfo->get() but it only return the id of the user.

                  Am I doing something wrong? Here is the code that I am using...

                  require_once '../../src/Google_Client.php';
                  require_once '../../src/contrib/Google_Oauth2Service.php';
                  
                  session_start();
                  
                  $client = new Google_Client();
                  $client->setApplicationName("Google+ PHP Starter Application");
                  // Visit https://code.google.com/apis/console to generate your
                  // oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri.
                   $client->setClientId('*********************');
                   $client->setClientSecret('**************');
                   $client->setRedirectUri('***************');
                   $client->setDeveloperKey('**************');
                  $plus = new Google_Oauth2Service($client);
                  
                  if (isset($_REQUEST['logout'])) {
                    unset($_SESSION['access_token']);
                  }
                  
                  if (isset($_GET['code'])) {
                    $client->authenticate($_GET['code']);
                    $_SESSION['access_token'] = $client->getAccessToken();
                    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
                  }
                  
                  if (isset($_SESSION['access_token'])) {
                    $client->setAccessToken($_SESSION['access_token']);
                  }
                  
                  if ($client->getAccessToken()) 
                  {
                      $userinfo = $plus->userinfo;
                      print_r($userinfo->get());
                  
                  } else 
                  {
                      $authUrl = $client->createAuthUrl();
                  }
                  ?>
                  <!doctype html>
                  <html>
                  <head>
                    <meta charset="utf-8">
                    <link rel='stylesheet' href='style.css' />
                  </head>
                  <body>
                  <header><h1>Google+ Sample App</h1></header>
                  <div class="box">
                  
                  <?php if(isset($personMarkup)): ?>
                  <div class="me"><?php print $personMarkup ?></div>
                  <?php endif ?>
                  
                  <?php
                    if(isset($authUrl)) {
                      print "<a class='login' href='$authUrl'>Connect Me!</a>";
                    } else {
                     print "<a class='logout' href='?logout'>Logout</a>";
                    }
                  ?>
                  </div>
                  </body>
                  </html>
                  

                  Thanks...

                  **EDIT*** Was missing Scopes--Added

                   $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'));
                  

                  works now...

                  解決方案

                  Was missing scopes

                  $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile'));
                  

                  Works like a charm now!

                  這篇關(guān)于從 Google OAuth 2.0 PHP API 獲取用戶信息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)

                  <small id='HSlyv'></small><noframes id='HSlyv'>

                      <tfoot id='HSlyv'></tfoot>

                      <i id='HSlyv'><tr id='HSlyv'><dt id='HSlyv'><q id='HSlyv'><span id='HSlyv'><b id='HSlyv'><form id='HSlyv'><ins id='HSlyv'></ins><ul id='HSlyv'></ul><sub id='HSlyv'></sub></form><legend id='HSlyv'></legend><bdo id='HSlyv'><pre id='HSlyv'><center id='HSlyv'></center></pre></bdo></b><th id='HSlyv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='HSlyv'><tfoot id='HSlyv'></tfoot><dl id='HSlyv'><fieldset id='HSlyv'></fieldset></dl></div>
                        <bdo id='HSlyv'></bdo><ul id='HSlyv'></ul>
                          <tbody id='HSlyv'></tbody>

                          <legend id='HSlyv'><style id='HSlyv'><dir id='HSlyv'><q id='HSlyv'></q></dir></style></legend>
                          主站蜘蛛池模板: 亚洲精品一区二区 | 黄色骚片 | 中国美女一级黄色片 | 亚洲欧美日韩网站 | 在线日韩 | 国产黄色av网站 | 一区二区三区在线免费观看视频 | 成人午夜激情 | 人操人免费视频 | 99精品国产一区二区三区 | 国产精品一二三区 | 亚洲精品第一国产综合野 | 欧美久久久久久久久 | 国产 日韩 欧美 在线 | 三级成人在线观看 | 91免费小视频 | 免费视频二区 | 午夜视频一区二区三区 | 国产中文视频 | 久久天天 | 拍拍无遮挡人做人爱视频免费观看 | 国产精品美女在线观看 | 欧美日韩不卡 | 国产福利91精品一区二区三区 | 国产三级网站 | 中文字幕第三页 | 久久综合影院 | 色综合99 | 天堂综合| 国产亚洲成av人片在线观看桃 | 91一区| 情侣酒店偷拍一区二区在线播放 | 黄网站涩免费蜜桃网站 | 玖玖视频国产 | 国产不卡视频在线 | 成人精品国产一区二区4080 | 天天色av| 国产高清免费 | 精品视频一区二区在线观看 | 国产精品免费一区二区三区 | 一本一道久久a久久精品蜜桃 |