diff options
Diffstat (limited to 'vendor/OAuth/OAuth1')
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/AbstractService.php | 305 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/BitBucket.php | 96 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/Etsy.php | 132 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/FitBit.php | 96 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/Flickr.php | 91 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/ScoopIt.php | 96 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/ServiceInterface.php | 45 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/Tumblr.php | 96 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/Twitter.php | 121 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/Xing.php | 96 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Service/Yahoo.php | 96 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php | 12 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Signature/Signature.php | 132 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Signature/SignatureInterface.php | 28 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Token/StdOAuth1Token.php | 75 | ||||
-rwxr-xr-x | vendor/OAuth/OAuth1/Token/TokenInterface.php | 41 |
16 files changed, 0 insertions, 1558 deletions
diff --git a/vendor/OAuth/OAuth1/Service/AbstractService.php b/vendor/OAuth/OAuth1/Service/AbstractService.php deleted file mode 100755 index 43c9c9f6..00000000 --- a/vendor/OAuth/OAuth1/Service/AbstractService.php +++ /dev/null @@ -1,305 +0,0 @@ -<?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; - } - - /** - * 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()); - $parameters = $this->getBasicAuthorizationHeaderInfo(); - if (isset($parameters['oauth_callback'])) { - unset($parameters['oauth_callback']); - } - - $parameters = array_merge($parameters, array('oauth_token' => $token->getAccessToken())); - $parameters = (is_array($bodyParams)) ? array_merge($parameters, $bodyParams) : $parameters; - $parameters['oauth_signature'] = $this->signature->getSignature($uri, $parameters, $method); - - $authorizationHeader = 'OAuth '; - $delimiter = ''; - - foreach ($parameters 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); -} diff --git a/vendor/OAuth/OAuth1/Service/BitBucket.php b/vendor/OAuth/OAuth1/Service/BitBucket.php deleted file mode 100755 index f6d8edfe..00000000 --- a/vendor/OAuth/OAuth1/Service/BitBucket.php +++ /dev/null @@ -1,96 +0,0 @@ -<?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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/Etsy.php b/vendor/OAuth/OAuth1/Service/Etsy.php deleted file mode 100755 index 30dc331c..00000000 --- a/vendor/OAuth/OAuth1/Service/Etsy.php +++ /dev/null @@ -1,132 +0,0 @@ -<?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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/FitBit.php b/vendor/OAuth/OAuth1/Service/FitBit.php deleted file mode 100755 index 78032d75..00000000 --- a/vendor/OAuth/OAuth1/Service/FitBit.php +++ /dev/null @@ -1,96 +0,0 @@ -<?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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/Flickr.php b/vendor/OAuth/OAuth1/Service/Flickr.php deleted file mode 100755 index f06d282a..00000000 --- a/vendor/OAuth/OAuth1/Service/Flickr.php +++ /dev/null @@ -1,91 +0,0 @@ -<?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 -{ - - 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); - - $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); - } -} diff --git a/vendor/OAuth/OAuth1/Service/ScoopIt.php b/vendor/OAuth/OAuth1/Service/ScoopIt.php deleted file mode 100755 index 28bd250b..00000000 --- a/vendor/OAuth/OAuth1/Service/ScoopIt.php +++ /dev/null @@ -1,96 +0,0 @@ -<?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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/ServiceInterface.php b/vendor/OAuth/OAuth1/Service/ServiceInterface.php deleted file mode 100755 index 3f91fbf2..00000000 --- a/vendor/OAuth/OAuth1/Service/ServiceInterface.php +++ /dev/null @@ -1,45 +0,0 @@ -<?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(); -} diff --git a/vendor/OAuth/OAuth1/Service/Tumblr.php b/vendor/OAuth/OAuth1/Service/Tumblr.php deleted file mode 100755 index 3f5d38a8..00000000 --- a/vendor/OAuth/OAuth1/Service/Tumblr.php +++ /dev/null @@ -1,96 +0,0 @@ -<?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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/Twitter.php b/vendor/OAuth/OAuth1/Service/Twitter.php deleted file mode 100755 index f46c34e4..00000000 --- a/vendor/OAuth/OAuth1/Service/Twitter.php +++ /dev/null @@ -1,121 +0,0 @@ -<?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.'); - } 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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/Xing.php b/vendor/OAuth/OAuth1/Service/Xing.php deleted file mode 100755 index 03e3357f..00000000 --- a/vendor/OAuth/OAuth1/Service/Xing.php +++ /dev/null @@ -1,96 +0,0 @@ -<?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); - - 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; - } -} diff --git a/vendor/OAuth/OAuth1/Service/Yahoo.php b/vendor/OAuth/OAuth1/Service/Yahoo.php deleted file mode 100755 index cff291d4..00000000 --- a/vendor/OAuth/OAuth1/Service/Yahoo.php +++ /dev/null @@ -1,96 +0,0 @@ -<?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 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} - */ - 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; - } -} diff --git a/vendor/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php b/vendor/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php deleted file mode 100755 index 44c36ce7..00000000 --- a/vendor/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?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 -{ -} diff --git a/vendor/OAuth/OAuth1/Signature/Signature.php b/vendor/OAuth/OAuth1/Signature/Signature.php deleted file mode 100755 index 2e13eb37..00000000 --- a/vendor/OAuth/OAuth1/Signature/Signature.php +++ /dev/null @@ -1,132 +0,0 @@ -<?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.' - ); - } - } -} diff --git a/vendor/OAuth/OAuth1/Signature/SignatureInterface.php b/vendor/OAuth/OAuth1/Signature/SignatureInterface.php deleted file mode 100755 index da50ddb6..00000000 --- a/vendor/OAuth/OAuth1/Signature/SignatureInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -<?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'); -} diff --git a/vendor/OAuth/OAuth1/Token/StdOAuth1Token.php b/vendor/OAuth/OAuth1/Token/StdOAuth1Token.php deleted file mode 100755 index a12a7971..00000000 --- a/vendor/OAuth/OAuth1/Token/StdOAuth1Token.php +++ /dev/null @@ -1,75 +0,0 @@ -<?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; - } -} diff --git a/vendor/OAuth/OAuth1/Token/TokenInterface.php b/vendor/OAuth/OAuth1/Token/TokenInterface.php deleted file mode 100755 index 0bc3f739..00000000 --- a/vendor/OAuth/OAuth1/Token/TokenInterface.php +++ /dev/null @@ -1,41 +0,0 @@ -<?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); -} |