summaryrefslogtreecommitdiff
path: root/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-06 06:41:47 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-06 06:41:47 -0500
commitc80c15dcc33a70acc2b177691d33f088f8c2541e (patch)
treebc3e44e35b97b751c145cc5797a0faf356922244 /vendor/lusitanian/oauth/src/OAuth/OAuth1/Service
parentc91ff61cdfa8b5eb76783927e5b8710f2a9f2601 (diff)
Include all vendor files in the repo to be easier for people
Diffstat (limited to 'vendor/lusitanian/oauth/src/OAuth/OAuth1/Service')
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php305
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php96
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php132
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php96
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php91
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php96
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php45
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php96
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php121
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php96
-rw-r--r--vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php96
11 files changed, 1270 insertions, 0 deletions
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
new file mode 100644
index 00000000..43c9c9f6
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
@@ -0,0 +1,305 @@
+<?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/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php
new file mode 100644
index 00000000..f6d8edfe
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php
@@ -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;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
new file mode 100644
index 00000000..30dc331c
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
@@ -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;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php
new file mode 100644
index 00000000..78032d75
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php
@@ -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;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
new file mode 100644
index 00000000..f06d282a
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
@@ -0,0 +1,91 @@
+<?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/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php
new file mode 100644
index 00000000..28bd250b
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php
@@ -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;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php
new file mode 100644
index 00000000..3f91fbf2
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php
@@ -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();
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php
new file mode 100644
index 00000000..3f5d38a8
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php
@@ -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;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
new file mode 100644
index 00000000..f46c34e4
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
@@ -0,0 +1,121 @@
+<?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/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
new file mode 100644
index 00000000..03e3357f
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
@@ -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 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/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php
new file mode 100644
index 00000000..cff291d4
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php
@@ -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 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;
+ }
+}