本文整理汇总了PHP中OAuth\OAuth2\Token\StdOAuth2Token::setEndOfLife方法的典型用法代码示例。如果您正苦于以下问题:PHP StdOAuth2Token::setEndOfLife方法的具体用法?PHP StdOAuth2Token::setEndOfLife怎么用?PHP StdOAuth2Token::setEndOfLife使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuth\OAuth2\Token\StdOAuth2Token
的用法示例。
在下文中一共展示了StdOAuth2Token::setEndOfLife方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseAccessTokenResponse
/**
* {@inheritdoc}
*/
protected function parseAccessTokenResponse($responseBody)
{
$data = json_decode($responseBody, true);
if (null === $data || !is_array($data)) {
throw new TokenResponseException('Unable to parse response.');
} elseif (isset($data['error'])) {
throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
}
$token = new StdOAuth2Token();
$token->setAccessToken($data['access_token']);
// Salesforce access tokens depend on the session timeout settings.
// The session timeout for an access token can be configured in Salesforce from Setup by clicking Security Controls | Session Settings.
$token->setEndOfLife(StdOAuth2Token::EOL_UNKNOWN);
unset($data['access_token']);
if (isset($data['refresh_token'])) {
$token->setRefreshToken($data['refresh_token']);
// Save Refresh Token persistently until it is cleared manually
update_option('gf_salesforce_refreshtoken', $data['refresh_token']);
unset($data['refresh_token']);
} else {
$refresh_token = get_option('gf_salesforce_refreshtoken');
if (!empty($refresh_token)) {
$token->setRefreshToken($refresh_token);
}
}
$token->setExtraParams($data);
return $token;
}
示例2: parseAccessTokenResponse
/**
* Parses the access token response and returns a TokenInterface.
*
*
* @param string $responseBody
*
* @return TokenInterface
*
* @throws TokenResponseException
*/
protected function parseAccessTokenResponse($responseBody)
{
$data = json_decode($responseBody, true);
if (null === $data || !is_array($data)) {
throw new TokenResponseException('Unable to parse response.');
} elseif (isset($data['error'])) {
throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
}
$token = new StdOAuth2Token();
$token->setAccessToken($data['access_token']);
$token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
unset($data['access_token']);
$token->setExtraParams($data);
return $token;
}
示例3: arrayToToken
/**
* Create token object from array.
*
* @param array $data
* @return TokenInterface
*/
public function arrayToToken(array $data)
{
if ($data && array_key_exists('accessToken', $data) && array_key_exists('accessTokenSecret', $data) && array_key_exists('requestToken', $data) && array_key_exists('requestTokenSecret', $data) && array_key_exists('endOfLife', $data) && array_key_exists('extraParams', $data)) {
$token = new StdOAuth1Token($data['accessToken']);
$token->setAccessTokenSecret($data['accessTokenSecret']);
$token->setRequestToken($data['requestToken']);
$token->setRequestTokenSecret($data['requestTokenSecret']);
$token->setEndOfLife($data['endOfLife']);
$token->setExtraParams($data['extraParams']);
} elseif ($data && array_key_exists('accessToken', $data) && array_key_exists('refreshToken', $data) && array_key_exists('endOfLife', $data) && array_key_exists('extraParams', $data)) {
$token = new StdOAuth2Token($data['accessToken'], $data['refreshToken'], null, $data['extraParams']);
$token->setEndOfLife($data['endOfLife']);
}
if (!isset($token) || !$token) {
return null;
}
return $token;
}
示例4: getToken
/**
* Get token from storage
*
* @param string $provider
* @param int $key
* @return Token
*/
public function getToken($provider, $key)
{
$provider = ucfirst(strtolower($provider));
$data = $this['option']->get('oauth:token:' . $provider . ':' . $key);
if ($data && array_key_exists('accessToken', $data) && array_key_exists('accessTokenSecret', $data) && array_key_exists('requestToken', $data) && array_key_exists('requestTokenSecret', $data) && array_key_exists('endOfLife', $data) && array_key_exists('extraParams', $data)) {
$token = new StdOAuth1Token($data['accessToken']);
$token->setAccessTokenSecret($data['accessTokenSecret']);
$token->setRequestToken($data['requestToken']);
$token->setRequestTokenSecret($data['requestTokenSecret']);
$token->setEndOfLife($data['endOfLife']);
$token->setExtraParams($data['extraParams']);
} elseif ($data && array_key_exists('accessToken', $data) && array_key_exists('refreshToken', $data) && array_key_exists('endOfLife', $data) && array_key_exists('extraParams', $data)) {
$token = new StdOAuth2Token($data['accessToken'], $data['refreshToken'], null, $data['extraParams']);
$token->setEndOfLife($data['endOfLife']);
}
if (!isset($token) || !$token) {
return null;
}
return $token;
}
示例5: Credentials
<?php
use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Token\StdOAuth2Token;
require_once __DIR__ . '/../bootstrap.php';
$credentials = new Credentials($githubCredentials['key'], $githubCredentials['secret'], 'http://github.com');
$github = $serviceFactory->createService('GitHub', $credentials, $storage, array());
$token = new StdOAuth2Token();
$token->setAccessToken($githubCredentials['cli_token']);
$token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
$storage->storeAccessToken('GitHub', $token);
$stmt = $dbConnection->query('SELECT id, feed_id, repository FROM feeds_repositories ORDER BY id ASC');
$repositories = [];
$feeds = $stmt->fetchAll();
foreach ($feeds as $repository) {
$repositories[] = $repository['repository'];
}
$repositories = array_unique($repositories);
$result = [];
foreach ($repositories as $repository) {
$result[$repository] = json_decode($github->request('repos/' . $repository . '/releases'), true);
}
foreach ($feeds as $feed) {
$timestamp = new \DateTime();
foreach ($result[$feed['repository']] as $release) {
if (postExists($dbConnection, $feed['feed_id'], $release['id'])) {
continue;
}
$postId = addPost($dbConnection, $feed['id'], $release);
logAddition($dbConnection, $feed['feed_id'], $postId, $timestamp);
}