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


PHP Google_Client::prepareScopes方法代碼示例

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


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

示例1: testPrepareService

 public function testPrepareService()
 {
     $client = new Google_Client();
     $client->setScopes(array("scope1", "scope2"));
     $scopes = $client->prepareScopes();
     $this->assertEquals("scope1 scope2", $scopes);
     $client->setScopes(array("", "scope2"));
     $scopes = $client->prepareScopes();
     $this->assertEquals(" scope2", $scopes);
     $client->setScopes("scope2");
     $client->addScope("scope3");
     $client->addScope(array("scope4", "scope5"));
     $scopes = $client->prepareScopes();
     $this->assertEquals("scope2 scope3 scope4 scope5", $scopes);
     $client->setClientId('test1');
     $client->setRedirectUri('http://localhost/');
     $client->setState('xyz');
     $client->setScopes(array("http://test.com", "scope2"));
     $scopes = $client->prepareScopes();
     $this->assertEquals("http://test.com scope2", $scopes);
     $this->assertEquals('' . 'https://accounts.google.com/o/oauth2/auth' . '?response_type=code' . '&access_type=online' . '&client_id=test1' . '&redirect_uri=http%3A%2F%2Flocalhost%2F' . '&state=xyz' . '&scope=http%3A%2F%2Ftest.com%20scope2' . '&approval_prompt=auto', $client->createAuthUrl());
     $response = $this->getMock('Psr\\Http\\Message\\ResponseInterface');
     $response->expects($this->once())->method('getBody')->will($this->returnValue($this->getMock('Psr\\Http\\Message\\StreamInterface')));
     $http = $this->getMock('GuzzleHttp\\ClientInterface');
     $http->expects($this->once())->method('send')->will($this->returnValue($response));
     if ($this->isGuzzle5()) {
         $guzzle5Request = new GuzzleHttp\Message\Request('POST', '/');
         $http->expects($this->once())->method('createRequest')->will($this->returnValue($guzzle5Request));
     }
     $client->setHttpClient($http);
     $dr_service = new Google_Service_Drive($client);
     $this->assertInstanceOf('Google_Model', $dr_service->files->listFiles());
 }
開發者ID:jvidor,項目名稱:google-api-php-client,代碼行數:33,代碼來源:ClientTest.php

示例2: testPrepareService

 public function testPrepareService()
 {
     $client = new Google_Client();
     $client->setScopes(array("scope1", "scope2"));
     $scopes = $client->prepareScopes();
     $this->assertEquals("scope1 scope2", $scopes);
     $client->setScopes(array("", "scope2"));
     $scopes = $client->prepareScopes();
     $this->assertEquals(" scope2", $scopes);
     $client->setScopes("scope2");
     $client->addScope("scope3");
     $client->addScope(array("scope4", "scope5"));
     $scopes = $client->prepareScopes();
     $this->assertEquals("scope2 scope3 scope4 scope5", $scopes);
     $client->setClientId('test1');
     $client->setRedirectUri('http://localhost/');
     $client->setScopes(array("http://test.com", "scope2"));
     $scopes = $client->prepareScopes();
     $this->assertEquals("http://test.com scope2", $scopes);
     $this->assertEquals('' . 'https://accounts.google.com/o/oauth2/auth' . '?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2F' . '&client_id=test1' . '&scope=http%3A%2F%2Ftest.com+scope2&access_type=online' . '&approval_prompt=auto', $client->createAuthUrl());
     // This should not trigger a request.
     $client->setDefer(true);
     $dr_service = new Google_Service_Drive($client);
     $this->assertInstanceOf('Google_Http_Request', $dr_service->files->listFiles());
 }
開發者ID:te-koyama,項目名稱:openpne,代碼行數:25,代碼來源:ApiClientTest.php


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