Ajout du FR
Ajout du FR + correction du "functions.php"
This commit is contained in:
320
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
vendored
Normal file
320
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
vendored
Normal file
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\TokenInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Service\AbstractService as BaseAbstractService;
|
||||
|
||||
abstract class AbstractService extends BaseAbstractService implements ServiceInterface
|
||||
{
|
||||
/** @const OAUTH_VERSION */
|
||||
const OAUTH_VERSION = 1;
|
||||
|
||||
/** @var SignatureInterface */
|
||||
protected $signature;
|
||||
|
||||
/** @var UriInterface|null */
|
||||
protected $baseApiUri;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage);
|
||||
|
||||
$this->signature = $signature;
|
||||
$this->baseApiUri = $baseApiUri;
|
||||
|
||||
$this->signature->setHashingAlgorithm($this->getSignatureMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function requestRequestToken()
|
||||
{
|
||||
$authorizationHeader = array('Authorization' => $this->buildAuthorizationHeaderForTokenRequest());
|
||||
$headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders());
|
||||
|
||||
$responseBody = $this->httpClient->retrieveResponse($this->getRequestTokenEndpoint(), array(), $headers);
|
||||
|
||||
$token = $this->parseRequestTokenResponse($responseBody);
|
||||
$this->storage->storeAccessToken($this->service(), $token);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationUri(array $additionalParameters = array())
|
||||
{
|
||||
// Build the url
|
||||
$url = clone $this->getAuthorizationEndpoint();
|
||||
foreach ($additionalParameters as $key => $val) {
|
||||
$url->addToQuery($key, $val);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function requestAccessToken($token, $verifier, $tokenSecret = null)
|
||||
{
|
||||
if (is_null($tokenSecret)) {
|
||||
$storedRequestToken = $this->storage->retrieveAccessToken($this->service());
|
||||
$tokenSecret = $storedRequestToken->getRequestTokenSecret();
|
||||
}
|
||||
$this->signature->setTokenSecret($tokenSecret);
|
||||
|
||||
$bodyParams = array(
|
||||
'oauth_verifier' => $verifier,
|
||||
);
|
||||
|
||||
$authorizationHeader = array(
|
||||
'Authorization' => $this->buildAuthorizationHeaderForAPIRequest(
|
||||
'POST',
|
||||
$this->getAccessTokenEndpoint(),
|
||||
$this->storage->retrieveAccessToken($this->service()),
|
||||
$bodyParams
|
||||
)
|
||||
);
|
||||
|
||||
$headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders());
|
||||
|
||||
$responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers);
|
||||
|
||||
$token = $this->parseAccessTokenResponse($responseBody);
|
||||
$this->storage->storeAccessToken($this->service(), $token);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes an OAuth1 access token
|
||||
* @param TokenInterface $token
|
||||
* @return TokenInterface $token
|
||||
*/
|
||||
public function refreshAccessToken(TokenInterface $token)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an authenticated API request to the path provided.
|
||||
* If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used.
|
||||
*
|
||||
* @param string|UriInterface $path
|
||||
* @param string $method HTTP method
|
||||
* @param array $body Request body if applicable (key/value pairs)
|
||||
* @param array $extraHeaders Extra headers if applicable.
|
||||
* These will override service-specific any defaults.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
$uri = $this->determineRequestUriFromPath($path, $this->baseApiUri);
|
||||
|
||||
/** @var $token StdOAuth1Token */
|
||||
$token = $this->storage->retrieveAccessToken($this->service());
|
||||
$extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);
|
||||
$authorizationHeader = array(
|
||||
'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body)
|
||||
);
|
||||
$headers = array_merge($authorizationHeader, $extraHeaders);
|
||||
|
||||
return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return any additional headers always needed for this service implementation's OAuth calls.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExtraOAuthHeaders()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return any additional headers always needed for this service implementation's API calls.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExtraApiHeaders()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the authorization header for getting an access or request token.
|
||||
*
|
||||
* @param array $extraParameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = array())
|
||||
{
|
||||
$parameters = $this->getBasicAuthorizationHeaderInfo();
|
||||
$parameters = array_merge($parameters, $extraParameters);
|
||||
$parameters['oauth_signature'] = $this->signature->getSignature(
|
||||
$this->getRequestTokenEndpoint(),
|
||||
$parameters,
|
||||
'POST'
|
||||
);
|
||||
|
||||
$authorizationHeader = 'OAuth ';
|
||||
$delimiter = '';
|
||||
foreach ($parameters as $key => $value) {
|
||||
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
|
||||
|
||||
$delimiter = ', ';
|
||||
}
|
||||
|
||||
return $authorizationHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the authorization header for an authenticated API request
|
||||
*
|
||||
* @param string $method
|
||||
* @param UriInterface $uri The uri the request is headed
|
||||
* @param TokenInterface $token
|
||||
* @param array $bodyParams Request body if applicable (key/value pairs)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildAuthorizationHeaderForAPIRequest(
|
||||
$method,
|
||||
UriInterface $uri,
|
||||
TokenInterface $token,
|
||||
$bodyParams = null
|
||||
) {
|
||||
$this->signature->setTokenSecret($token->getAccessTokenSecret());
|
||||
$authParameters = $this->getBasicAuthorizationHeaderInfo();
|
||||
if (isset($authParameters['oauth_callback'])) {
|
||||
unset($authParameters['oauth_callback']);
|
||||
}
|
||||
|
||||
$authParameters = array_merge($authParameters, array('oauth_token' => $token->getAccessToken()));
|
||||
|
||||
$signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters;
|
||||
$authParameters['oauth_signature'] = $this->signature->getSignature($uri, $signatureParams, $method);
|
||||
|
||||
if (is_array($bodyParams) && isset($bodyParams['oauth_session_handle'])) {
|
||||
$authParameters['oauth_session_handle'] = $bodyParams['oauth_session_handle'];
|
||||
unset($bodyParams['oauth_session_handle']);
|
||||
}
|
||||
|
||||
$authorizationHeader = 'OAuth ';
|
||||
$delimiter = '';
|
||||
|
||||
foreach ($authParameters as $key => $value) {
|
||||
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
|
||||
$delimiter = ', ';
|
||||
}
|
||||
|
||||
return $authorizationHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the authorization header array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getBasicAuthorizationHeaderInfo()
|
||||
{
|
||||
$dateTime = new \DateTime();
|
||||
$headerParameters = array(
|
||||
'oauth_callback' => $this->credentials->getCallbackUrl(),
|
||||
'oauth_consumer_key' => $this->credentials->getConsumerId(),
|
||||
'oauth_nonce' => $this->generateNonce(),
|
||||
'oauth_signature_method' => $this->getSignatureMethod(),
|
||||
'oauth_timestamp' => $dateTime->format('U'),
|
||||
'oauth_version' => $this->getVersion(),
|
||||
);
|
||||
|
||||
return $headerParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pseudo random string generator used to build a unique string to sign each request
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateNonce($length = 32)
|
||||
{
|
||||
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
||||
|
||||
$nonce = '';
|
||||
$maxRand = strlen($characters)-1;
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$nonce.= $characters[rand(0, $maxRand)];
|
||||
}
|
||||
|
||||
return $nonce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSignatureMethod()
|
||||
{
|
||||
return 'HMAC-SHA1';
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the version used in the authorization header of the requests
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getVersion()
|
||||
{
|
||||
return '1.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the request token response and returns a TokenInterface.
|
||||
* This is only needed to verify the `oauth_callback_confirmed` parameter. The actual
|
||||
* parsing logic is contained in the access token parser.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @param string $responseBody
|
||||
*
|
||||
* @return TokenInterface
|
||||
*
|
||||
* @throws TokenResponseException
|
||||
*/
|
||||
abstract protected function parseRequestTokenResponse($responseBody);
|
||||
|
||||
/**
|
||||
* Parses the access token response and returns a TokenInterface.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @param string $responseBody
|
||||
*
|
||||
* @return TokenInterface
|
||||
*
|
||||
* @throws TokenResponseException
|
||||
*/
|
||||
abstract protected function parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php
vendored
Normal file
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class BitBucket extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://bitbucket.org/api/1.0/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://bitbucket.org/!api/1.0/oauth/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://bitbucket.org/!api/1.0/oauth/authenticate');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://bitbucket.org/!api/1.0/oauth/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
132
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
vendored
Normal file
132
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class Etsy extends AbstractService
|
||||
{
|
||||
|
||||
protected $scopes = array();
|
||||
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://openapi.etsy.com/v2/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
$uri = new Uri($this->baseApiUri . 'oauth/request_token');
|
||||
$scopes = $this->getScopes();
|
||||
|
||||
if (count($scopes)) {
|
||||
$uri->setQuery('scope=' . implode('%20', $scopes));
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri($this->baseApiUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri($this->baseApiUri . 'oauth/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scopes for permissions
|
||||
* @see https://www.etsy.com/developers/documentation/getting_started/oauth#section_permission_scopes
|
||||
* @param array $scopes
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setScopes(array $scopes)
|
||||
{
|
||||
if (!is_array($scopes)) {
|
||||
$scopes = array();
|
||||
}
|
||||
|
||||
$this->scopes = $scopes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the defined scopes
|
||||
* @return array
|
||||
*/
|
||||
public function getScopes()
|
||||
{
|
||||
return $this->scopes;
|
||||
}
|
||||
}
|
||||
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php
vendored
Normal file
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class FitBit extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://api.fitbit.com/1/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.fitbit.com/oauth/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://www.fitbit.com/oauth/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.fitbit.com/oauth/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
120
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php
vendored
Normal file
120
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* 500px service.
|
||||
*
|
||||
* @author Pedro Amorim <contact@pamorim.fr>
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link https://developers.500px.com/
|
||||
*/
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
/**
|
||||
* 500px service.
|
||||
*
|
||||
* @author Pedro Amorim <contact@pamorim.fr>
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link https://developers.500px.com/
|
||||
*/
|
||||
class FiveHundredPx extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct(
|
||||
$credentials,
|
||||
$httpClient,
|
||||
$storage,
|
||||
$signature,
|
||||
$baseApiUri
|
||||
);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://api.500px.com/v1/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.500px.com/v1/oauth/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://api.500px.com/v1/oauth/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.500px.com/v1/oauth/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed'])
|
||||
|| $data['oauth_callback_confirmed'] !== 'true'
|
||||
) {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
133
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
vendored
Normal file
133
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class Flickr extends AbstractService
|
||||
{
|
||||
protected $format;
|
||||
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
if ($baseApiUri === null) {
|
||||
$this->baseApiUri = new Uri('https://api.flickr.com/services/rest/');
|
||||
}
|
||||
}
|
||||
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://www.flickr.com/services/oauth/request_token');
|
||||
}
|
||||
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://www.flickr.com/services/oauth/authorize');
|
||||
}
|
||||
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://www.flickr.com/services/oauth/access_token');
|
||||
}
|
||||
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
if ($data === null || !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 StdOAuth1Token();
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
$uri = $this->determineRequestUriFromPath('/', $this->baseApiUri);
|
||||
$uri->addToQuery('method', $path);
|
||||
|
||||
if (!empty($this->format)) {
|
||||
$uri->addToQuery('format', $this->format);
|
||||
|
||||
if ($this->format === 'json') {
|
||||
$uri->addToQuery('nojsoncallback', 1);
|
||||
}
|
||||
}
|
||||
|
||||
$token = $this->storage->retrieveAccessToken($this->service());
|
||||
$extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);
|
||||
$authorizationHeader = array(
|
||||
'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body)
|
||||
);
|
||||
$headers = array_merge($authorizationHeader, $extraHeaders);
|
||||
|
||||
return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);
|
||||
}
|
||||
|
||||
public function requestRest($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
return $this->request($path, $method, $body, $extraHeaders);
|
||||
}
|
||||
|
||||
public function requestXmlrpc($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
$this->format = 'xmlrpc';
|
||||
|
||||
return $this->request($path, $method, $body, $extraHeaders);
|
||||
}
|
||||
|
||||
public function requestSoap($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
$this->format = 'soap';
|
||||
|
||||
return $this->request($path, $method, $body, $extraHeaders);
|
||||
}
|
||||
|
||||
public function requestJson($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
$this->format = 'json';
|
||||
|
||||
return $this->request($path, $method, $body, $extraHeaders);
|
||||
}
|
||||
|
||||
public function requestPhp($path, $method = 'GET', $body = null, array $extraHeaders = array())
|
||||
{
|
||||
$this->format = 'php_serial';
|
||||
|
||||
return $this->request($path, $method, $body, $extraHeaders);
|
||||
}
|
||||
}
|
||||
120
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php
vendored
Normal file
120
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
|
||||
class QuickBooks extends AbstractService
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct(
|
||||
$credentials,
|
||||
$httpClient,
|
||||
$storage,
|
||||
$signature,
|
||||
$baseApiUri
|
||||
);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://quickbooks.api.intuit.com/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://oauth.intuit.com/oauth/v1/get_request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://appcenter.intuit.com/Connect/Begin');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://oauth.intuit.com/oauth/v1/get_access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed'])
|
||||
|| $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (isset($data['error'])) {
|
||||
$message = 'Error in retrieving token: "' . $data['error'] . '"';
|
||||
throw new TokenResponseException($message);
|
||||
}
|
||||
|
||||
$token = new StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function request(
|
||||
$path,
|
||||
$method = 'GET',
|
||||
$body = null,
|
||||
array $extraHeaders = array()
|
||||
) {
|
||||
$extraHeaders['Accept'] = 'application/json';
|
||||
return parent::request($path, $method, $body, $extraHeaders);
|
||||
}
|
||||
}
|
||||
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php
vendored
Normal file
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class Redmine extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
throw new \Exception('baseApiUri is a required argument.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri($this->baseApiUri->getAbsoluteUri() . '/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri($this->baseApiUri->getAbsoluteUri() . '/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri($this->baseApiUri->getAbsoluteUri() . '/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php
vendored
Normal file
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class ScoopIt extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://www.scoop.it/api/1/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://www.scoop.it/oauth/request');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://www.scoop.it/oauth/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://www.scoop.it/oauth/access');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
45
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php
vendored
Normal file
45
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Token\TokenInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Service\ServiceInterface as BaseServiceInterface;
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
|
||||
/**
|
||||
* Defines the common methods across OAuth 1 services.
|
||||
*/
|
||||
interface ServiceInterface extends BaseServiceInterface
|
||||
{
|
||||
/**
|
||||
* Retrieves and stores/returns the OAuth1 request token obtained from the service.
|
||||
*
|
||||
* @return TokenInterface $token
|
||||
*
|
||||
* @throws TokenResponseException
|
||||
*/
|
||||
public function requestRequestToken();
|
||||
|
||||
/**
|
||||
* Retrieves and stores/returns the OAuth1 access token after a successful authorization.
|
||||
*
|
||||
* @param string $token The request token from the callback.
|
||||
* @param string $verifier
|
||||
* @param string $tokenSecret
|
||||
*
|
||||
* @return TokenInterface $token
|
||||
*
|
||||
* @throws TokenResponseException
|
||||
*/
|
||||
public function requestAccessToken($token, $verifier, $tokenSecret);
|
||||
|
||||
/**
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function getRequestTokenEndpoint();
|
||||
}
|
||||
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php
vendored
Normal file
96
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class Tumblr extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://api.tumblr.com/v2/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://www.tumblr.com/oauth/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://www.tumblr.com/oauth/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://www.tumblr.com/oauth/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
123
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
vendored
Normal file
123
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
use OAuth\Common\Exception\Exception;
|
||||
|
||||
class Twitter extends AbstractService
|
||||
{
|
||||
const ENDPOINT_AUTHENTICATE = "https://api.twitter.com/oauth/authenticate";
|
||||
const ENDPOINT_AUTHORIZE = "https://api.twitter.com/oauth/authorize";
|
||||
|
||||
protected $authorizationEndpoint = self::ENDPOINT_AUTHENTICATE;
|
||||
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://api.twitter.com/1.1/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.twitter.com/oauth/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
if ($this->authorizationEndpoint != self::ENDPOINT_AUTHENTICATE
|
||||
&& $this->authorizationEndpoint != self::ENDPOINT_AUTHORIZE) {
|
||||
$this->authorizationEndpoint = self::ENDPOINT_AUTHENTICATE;
|
||||
}
|
||||
return new Uri($this->authorizationEndpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $authorizationEndpoint
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setAuthorizationEndpoint($endpoint)
|
||||
{
|
||||
if ($endpoint != self::ENDPOINT_AUTHENTICATE && $endpoint != self::ENDPOINT_AUTHORIZE) {
|
||||
throw new Exception(
|
||||
sprintf("'%s' is not a correct Twitter authorization endpoint.", $endpoint)
|
||||
);
|
||||
}
|
||||
$this->authorizationEndpoint = $endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.twitter.com/oauth/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response: ' . $responseBody);
|
||||
} elseif (isset($data['error'])) {
|
||||
throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
|
||||
} elseif (!isset($data["oauth_token"]) || !isset($data["oauth_token_secret"])) {
|
||||
throw new TokenResponseException('Invalid response. OAuth Token data not set: ' . $responseBody);
|
||||
}
|
||||
|
||||
$token = new StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
97
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
vendored
Normal file
97
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
|
||||
class Xing extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://api.xing.com/v1/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://api.xing.com/v1/authorize');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.xing.com/v1/access_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.xing.com/v1/request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
$errors = json_decode($responseBody);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif ($errors) {
|
||||
throw new TokenResponseException('Error in retrieving token: "' . $errors->error_name . '"');
|
||||
}
|
||||
|
||||
$token = new StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
131
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php
vendored
Normal file
131
vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Service;
|
||||
|
||||
use OAuth\OAuth1\Signature\SignatureInterface;
|
||||
use OAuth\OAuth1\Token\StdOAuth1Token;
|
||||
use OAuth\Common\Http\Exception\TokenResponseException;
|
||||
use OAuth\Common\Http\Uri\Uri;
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Client\ClientInterface;
|
||||
use OAuth\OAuth1\Token\TokenInterface;
|
||||
|
||||
class Yahoo extends AbstractService
|
||||
{
|
||||
public function __construct(
|
||||
CredentialsInterface $credentials,
|
||||
ClientInterface $httpClient,
|
||||
TokenStorageInterface $storage,
|
||||
SignatureInterface $signature,
|
||||
UriInterface $baseApiUri = null
|
||||
) {
|
||||
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
|
||||
|
||||
if (null === $baseApiUri) {
|
||||
$this->baseApiUri = new Uri('https://social.yahooapis.com/v1/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRequestTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.login.yahoo.com/oauth/v2/get_request_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthorizationEndpoint()
|
||||
{
|
||||
return new Uri('https://api.login.yahoo.com/oauth/v2/request_auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAccessTokenEndpoint()
|
||||
{
|
||||
return new Uri('https://api.login.yahoo.com/oauth/v2/get_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function refreshAccessToken(TokenInterface $token)
|
||||
{
|
||||
$extraParams = $token->getExtraParams();
|
||||
$bodyParams = array('oauth_session_handle' => $extraParams['oauth_session_handle']);
|
||||
|
||||
$authorizationHeader = array(
|
||||
'Authorization' => $this->buildAuthorizationHeaderForAPIRequest(
|
||||
'POST',
|
||||
$this->getAccessTokenEndpoint(),
|
||||
$this->storage->retrieveAccessToken($this->service()),
|
||||
$bodyParams
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
$headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders(), array());
|
||||
|
||||
$responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers);
|
||||
|
||||
$token = $this->parseAccessTokenResponse($responseBody);
|
||||
$this->storage->storeAccessToken($this->service(), $token);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseRequestTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
if (null === $data || !is_array($data)) {
|
||||
throw new TokenResponseException('Unable to parse response.');
|
||||
} elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') {
|
||||
throw new TokenResponseException('Error in retrieving token.');
|
||||
}
|
||||
|
||||
return $this->parseAccessTokenResponse($responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function parseAccessTokenResponse($responseBody)
|
||||
{
|
||||
parse_str($responseBody, $data);
|
||||
|
||||
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 StdOAuth1Token();
|
||||
|
||||
$token->setRequestToken($data['oauth_token']);
|
||||
$token->setRequestTokenSecret($data['oauth_token_secret']);
|
||||
$token->setAccessToken($data['oauth_token']);
|
||||
$token->setAccessTokenSecret($data['oauth_token_secret']);
|
||||
|
||||
if (isset($data['oauth_expires_in'])) {
|
||||
$token->setLifetime($data['oauth_expires_in']);
|
||||
} else {
|
||||
$token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
|
||||
}
|
||||
|
||||
unset($data['oauth_token'], $data['oauth_token_secret']);
|
||||
$token->setExtraParams($data);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Signature\Exception;
|
||||
|
||||
use OAuth\Common\Exception\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when an unsupported hash mechanism is requested in signature class.
|
||||
*/
|
||||
class UnsupportedHashAlgorithmException extends Exception
|
||||
{
|
||||
}
|
||||
132
vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php
vendored
Normal file
132
vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Signature;
|
||||
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
use OAuth\OAuth1\Signature\Exception\UnsupportedHashAlgorithmException;
|
||||
|
||||
class Signature implements SignatureInterface
|
||||
{
|
||||
/**
|
||||
* @var Credentials
|
||||
*/
|
||||
protected $credentials;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $algorithm;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tokenSecret = null;
|
||||
|
||||
/**
|
||||
* @param CredentialsInterface $credentials
|
||||
*/
|
||||
public function __construct(CredentialsInterface $credentials)
|
||||
{
|
||||
$this->credentials = $credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $algorithm
|
||||
*/
|
||||
public function setHashingAlgorithm($algorithm)
|
||||
{
|
||||
$this->algorithm = $algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
*/
|
||||
public function setTokenSecret($token)
|
||||
{
|
||||
$this->tokenSecret = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UriInterface $uri
|
||||
* @param array $params
|
||||
* @param string $method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSignature(UriInterface $uri, array $params, $method = 'POST')
|
||||
{
|
||||
parse_str($uri->getQuery(), $queryStringData);
|
||||
|
||||
foreach (array_merge($queryStringData, $params) as $key => $value) {
|
||||
$signatureData[rawurlencode($key)] = rawurlencode($value);
|
||||
}
|
||||
|
||||
ksort($signatureData);
|
||||
|
||||
// determine base uri
|
||||
$baseUri = $uri->getScheme() . '://' . $uri->getRawAuthority();
|
||||
|
||||
if ('/' === $uri->getPath()) {
|
||||
$baseUri .= $uri->hasExplicitTrailingHostSlash() ? '/' : '';
|
||||
} else {
|
||||
$baseUri .= $uri->getPath();
|
||||
}
|
||||
|
||||
$baseString = strtoupper($method) . '&';
|
||||
$baseString .= rawurlencode($baseUri) . '&';
|
||||
$baseString .= rawurlencode($this->buildSignatureDataString($signatureData));
|
||||
|
||||
return base64_encode($this->hash($baseString));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $signatureData
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildSignatureDataString(array $signatureData)
|
||||
{
|
||||
$signatureString = '';
|
||||
$delimiter = '';
|
||||
foreach ($signatureData as $key => $value) {
|
||||
$signatureString .= $delimiter . $key . '=' . $value;
|
||||
|
||||
$delimiter = '&';
|
||||
}
|
||||
|
||||
return $signatureString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSigningKey()
|
||||
{
|
||||
$signingKey = rawurlencode($this->credentials->getConsumerSecret()) . '&';
|
||||
if ($this->tokenSecret !== null) {
|
||||
$signingKey .= rawurlencode($this->tokenSecret);
|
||||
}
|
||||
|
||||
return $signingKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws UnsupportedHashAlgorithmException
|
||||
*/
|
||||
protected function hash($data)
|
||||
{
|
||||
switch (strtoupper($this->algorithm)) {
|
||||
case 'HMAC-SHA1':
|
||||
return hash_hmac('sha1', $data, $this->getSigningKey(), true);
|
||||
default:
|
||||
throw new UnsupportedHashAlgorithmException(
|
||||
'Unsupported hashing algorithm (' . $this->algorithm . ') used.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php
vendored
Normal file
28
vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Signature;
|
||||
|
||||
use OAuth\Common\Consumer\CredentialsInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
|
||||
interface SignatureInterface
|
||||
{
|
||||
/**
|
||||
* @param string $algorithm
|
||||
*/
|
||||
public function setHashingAlgorithm($algorithm);
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
*/
|
||||
public function setTokenSecret($token);
|
||||
|
||||
/**
|
||||
* @param UriInterface $uri
|
||||
* @param array $params
|
||||
* @param string $method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSignature(UriInterface $uri, array $params, $method = 'POST');
|
||||
}
|
||||
75
vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php
vendored
Normal file
75
vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Token;
|
||||
|
||||
use OAuth\Common\Token\AbstractToken;
|
||||
|
||||
/**
|
||||
* Standard OAuth1 token implementation.
|
||||
* Implements OAuth\OAuth1\Token\TokenInterface in case of any OAuth1 specific features.
|
||||
*/
|
||||
class StdOAuth1Token extends AbstractToken implements TokenInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $requestToken;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $requestTokenSecret;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $accessTokenSecret;
|
||||
|
||||
/**
|
||||
* @param string $requestToken
|
||||
*/
|
||||
public function setRequestToken($requestToken)
|
||||
{
|
||||
$this->requestToken = $requestToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestToken()
|
||||
{
|
||||
return $this->requestToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $requestTokenSecret
|
||||
*/
|
||||
public function setRequestTokenSecret($requestTokenSecret)
|
||||
{
|
||||
$this->requestTokenSecret = $requestTokenSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestTokenSecret()
|
||||
{
|
||||
return $this->requestTokenSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessTokenSecret
|
||||
*/
|
||||
public function setAccessTokenSecret($accessTokenSecret)
|
||||
{
|
||||
$this->accessTokenSecret = $accessTokenSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessTokenSecret()
|
||||
{
|
||||
return $this->accessTokenSecret;
|
||||
}
|
||||
}
|
||||
41
vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php
vendored
Normal file
41
vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace OAuth\OAuth1\Token;
|
||||
|
||||
use OAuth\Common\Token\TokenInterface as BaseTokenInterface;
|
||||
|
||||
/**
|
||||
* OAuth1 specific token interface
|
||||
*/
|
||||
interface TokenInterface extends BaseTokenInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessTokenSecret();
|
||||
|
||||
/**
|
||||
* @param string $accessTokenSecret
|
||||
*/
|
||||
public function setAccessTokenSecret($accessTokenSecret);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestTokenSecret();
|
||||
|
||||
/**
|
||||
* @param string $requestTokenSecret
|
||||
*/
|
||||
public function setRequestTokenSecret($requestTokenSecret);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestToken();
|
||||
|
||||
/**
|
||||
* @param string $requestToken
|
||||
*/
|
||||
public function setRequestToken($requestToken);
|
||||
}
|
||||
Reference in New Issue
Block a user