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


PHP apiClient::getAuth方法代碼示例

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


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

示例1: getServiceClient

 public static function getServiceClient()
 {
     if (!self::isServiceConfigured()) {
         return false;
     }
     $config = self::getConfig();
     $client = new apiClient(array("ioFileCache_directory" => PIMCORE_CACHE_DIRECTORY));
     $client->setApplicationName("pimcore CMF");
     $key = file_get_contents(self::getPrivateKeyPath());
     $client->setAssertionCredentials(new apiAssertionCredentials($config->email, array('https://www.googleapis.com/auth/analytics.readonly', "https://www.google.com/webmasters/tools/feeds/"), $key));
     $client->setClientId($config->client_id);
     // token cache
     $tokenFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/google-api.token";
     if (file_exists($tokenFile)) {
         $tokenData = file_get_contents($tokenFile);
         $tokenInfo = Zend_Json::decode($tokenData);
         if ($tokenInfo["created"] + $tokenInfo["expires_in"] > time() - 900) {
             $token = $tokenData;
         }
     }
     if (!$token) {
         $client->getAuth()->refreshTokenWithAssertion();
         $token = $client->getAuth()->getAccessToken();
         file_put_contents($tokenFile, $token);
     }
     $client->setAccessToken($token);
     return $client;
 }
開發者ID:shanky0110,項目名稱:pimcore-custom,代碼行數:28,代碼來源:Api.php

示例2: testSettersGetters

 public function testSettersGetters()
 {
     $client = new apiClient();
     $client->setClientId("client1");
     $client->setClientSecret('client1secret');
     $client->setState('1');
     $client->setApprovalPrompt('force');
     $client->setAccessType('offline');
     global $apiConfig;
     $this->assertEquals('client1', $apiConfig['oauth2_client_id']);
     $this->assertEquals('client1secret', $apiConfig['oauth2_client_secret']);
     $client->setRedirectUri('localhost');
     $client->setApplicationName('me');
     $client->setUseObjects(false);
     $this->assertEquals('object', gettype($client->getAuth()));
     $this->assertEquals('object', gettype($client->getCache()));
     $this->assertEquals('object', gettype($client->getIo()));
     $client->setAuthClass('apiAuthNone');
     $client->setAuthClass('apiOAuth2');
     try {
         $client->setAccessToken(null);
         die('Should have thrown an apiAuthException.');
     } catch (apiAuthException $e) {
         $this->assertEquals('Could not json decode the access token', $e->getMessage());
     }
     $token = json_encode(array('access_token' => 'token'));
     $client->setAccessToken($token);
     $this->assertEquals($token, $client->getAccessToken());
 }
開發者ID:rahij,項目名稱:ivlesync,代碼行數:29,代碼來源:ApiClientTest.php


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