本文整理汇总了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());
}