[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace OAuth\OAuth1\Service; 4 5 use Exception; 6 use OAuth\Common\Consumer\CredentialsInterface; 7 use OAuth\Common\Http\Client\ClientInterface; 8 use OAuth\Common\Http\Exception\TokenResponseException; 9 use OAuth\Common\Http\Uri\Uri; 10 use OAuth\Common\Http\Uri\UriInterface; 11 use OAuth\Common\Storage\TokenStorageInterface; 12 use OAuth\OAuth1\Signature\SignatureInterface; 13 use OAuth\OAuth1\Token\StdOAuth1Token; 14 15 class Redmine extends AbstractService 16 { 17 public function __construct( 18 CredentialsInterface $credentials, 19 ClientInterface $httpClient, 20 TokenStorageInterface $storage, 21 SignatureInterface $signature, 22 UriInterface $baseApiUri 23 ) { 24 parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); 25 26 if (null === $baseApiUri) { 27 throw new Exception('baseApiUri is a required argument.'); 28 } 29 } 30 31 /** 32 * {@inheritdoc} 33 */ 34 public function getRequestTokenEndpoint() 35 { 36 return new Uri($this->baseApiUri->getAbsoluteUri() . '/request_token'); 37 } 38 39 /** 40 * {@inheritdoc} 41 */ 42 public function getAuthorizationEndpoint() 43 { 44 return new Uri($this->baseApiUri->getAbsoluteUri() . '/authorize'); 45 } 46 47 /** 48 * {@inheritdoc} 49 */ 50 public function getAccessTokenEndpoint() 51 { 52 return new Uri($this->baseApiUri->getAbsoluteUri() . '/access_token'); 53 } 54 55 /** 56 * {@inheritdoc} 57 */ 58 protected function parseRequestTokenResponse($responseBody) 59 { 60 parse_str($responseBody, $data); 61 62 if (null === $data || !is_array($data)) { 63 throw new TokenResponseException('Unable to parse response.'); 64 } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { 65 throw new TokenResponseException('Error in retrieving token.'); 66 } 67 68 return $this->parseAccessTokenResponse($responseBody); 69 } 70 71 /** 72 * {@inheritdoc} 73 */ 74 protected function parseAccessTokenResponse($responseBody) 75 { 76 parse_str($responseBody, $data); 77 78 if (null === $data || !is_array($data)) { 79 throw new TokenResponseException('Unable to parse response.'); 80 } elseif (isset($data['error'])) { 81 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 82 } 83 84 $token = new StdOAuth1Token(); 85 86 $token->setRequestToken($data['oauth_token']); 87 $token->setRequestTokenSecret($data['oauth_token_secret']); 88 $token->setAccessToken($data['oauth_token']); 89 $token->setAccessTokenSecret($data['oauth_token_secret']); 90 91 $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); 92 unset($data['oauth_token'], $data['oauth_token_secret']); 93 $token->setExtraParams($data); 94 95 return $token; 96 } 97 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |