當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Google_Client::getScopes方法代碼示例

本文整理匯總了PHP中Google_Client::getScopes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Google_Client::getScopes方法的具體用法?PHP Google_Client::getScopes怎麽用?PHP Google_Client::getScopes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Google_Client的用法示例。


在下文中一共展示了Google_Client::getScopes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getClient

 protected function getClient()
 {
     if (null === $this->client) {
         $this->client = new \Google_Client();
         $this->client->setAuthConfig($this->credentials);
         $this->client->setApplicationName($this->name);
         foreach ($this->services as $serviceName => $service) {
             if (!isset($service['class'])) {
                 throw new InvalidConfigException("Not set service class for service \"{$serviceName}\"");
             }
             $service['scopes'] = (array) $service['scopes'];
             if (empty($service['scopes'])) {
                 throw new InvalidConfigException("Not set scopes for service \"{$serviceName}\"");
             }
             $this->client->addScope($service["scopes"]);
         }
         $scopes = $this->client->getScopes();
         if (empty($scopes)) {
             throw new InvalidConfigException("Not set scopes for application \"{$this->name}\"");
         }
     }
     return $this->client;
 }
開發者ID:gillbeits,項目名稱:yii2-google-api,代碼行數:23,代碼來源:GoogleApi.php

示例2: connectDrive

 public function connectDrive()
 {
     $this->autoRender = false;
     $this->loadModel('Tokens');
     // GAUTH: connect drive
     $client = new \Google_Client();
     $client->setAuthConfigFile('../client_secret.json');
     $client->addScope(\Google_Service_Drive::DRIVE);
     $client->authenticate($this->request->query['code']);
     $drive_token = $client->getAccessToken();
     $this->request->session()->write('user.drive_token', $drive_token);
     $data = ['user_id' => $this->request->session()->read('user.id'), 'scope' => implode(" ", $client->getScopes()), 'type' => 'refresh', 'token' => json_decode($drive_token)->refresh_token];
     $newToken = $this->Tokens->newEntity($data);
     $this->Tokens->save($newToken);
     return $this->redirect(['controller' => 'Player']);
 }
開發者ID:apomarinov,項目名稱:cake,代碼行數:16,代碼來源:UsersController.php


注:本文中的Google_Client::getScopes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。