本文整理匯總了PHP中Google_Client::setConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP Google_Client::setConfig方法的具體用法?PHP Google_Client::setConfig怎麽用?PHP Google_Client::setConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Google_Client
的用法示例。
在下文中一共展示了Google_Client::setConfig方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tryToGetAnAccessToken
public function tryToGetAnAccessToken(Google_Client $client)
{
$this->checkClientCredentials();
$client->setRedirectUri("urn:ietf:wg:oauth:2.0:oob");
$client->setConfig('access_type', 'offline');
$authUrl = $client->createAuthUrl();
echo "\nPlease enter the auth code:\n";
ob_flush();
`open '{$authUrl}'`;
$authCode = trim(fgets(STDIN));
if ($accessToken = $client->fetchAccessTokenWithAuthCode($authCode)) {
if (isset($accessToken['access_token'])) {
return $accessToken;
}
}
return false;
}
示例2: testSettersGetters
public function testSettersGetters()
{
$client = new Google_Client();
$client->setClientId("client1");
$client->setClientSecret('client1secret');
$client->setState('1');
$client->setApprovalPrompt('force');
$client->setAccessType('offline');
$client->setRedirectUri('localhost');
$client->setConfig('application_name', 'me');
$client->setCache($this->getMock('Psr\\Cache\\CacheItemPoolInterface'));
$this->assertEquals('object', gettype($client->getCache()));
try {
$client->setAccessToken(null);
$this->fail('Should have thrown an Exception.');
} catch (InvalidArgumentException $e) {
$this->assertEquals('invalid json token', $e->getMessage());
}
$token = array('access_token' => 'token');
$client->setAccessToken($token);
$this->assertEquals($token, $client->getAccessToken());
}