Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Vimeo.php
001 <?php
002 /**
003 * Vimeo service.
004 *
005 * @author Pedro Amorim <contact@pamorim.fr>
006 * @license http://www.opensource.org/licenses/mit-license.html MIT License
007 *
008 * @see https://developer.vimeo.com/
009 * @see https://developer.vimeo.com/api/authentication
010 */
011
012 namespace OAuth\OAuth2\Service;
013
014 use OAuth\Common\Consumer\CredentialsInterface;
015 use OAuth\Common\Http\Client\ClientInterface;
016 use OAuth\Common\Http\Exception\TokenResponseException;
017 use OAuth\Common\Http\Uri\Uri;
018 use OAuth\Common\Http\Uri\UriInterface;
019 use OAuth\Common\Storage\TokenStorageInterface;
020 use OAuth\OAuth2\Token\StdOAuth2Token;
021
022 /**
023 * Vimeo service.
024 *
025 * @author Pedro Amorim <contact@pamorim.fr>
026 * @license http://www.opensource.org/licenses/mit-license.html MIT License
027 *
028 * @see https://developer.vimeo.com/
029 * @see https://developer.vimeo.com/api/authentication
030 */
031 class Vimeo extends AbstractService
032 {
033 // API version
034 const VERSION = '3.2';
035 // API Header Accept
036 const HEADER_ACCEPT = 'application/vnd.vimeo.*+json;version=3.2';
037
038 /**
039 * Scopes.
040 *
041 * @see https://developer.vimeo.com/api/authentication#scope
042 */
043 // View public videos
044 const SCOPE_PUBLIC = 'public';
045 // View private videos
046 const SCOPE_PRIVATE = 'private';
047 // View Vimeo On Demand purchase history
048 const SCOPE_PURCHASED = 'purchased';
049 // Create new videos, groups, albums, etc.
050 const SCOPE_CREATE = 'create';
051 // Edit videos, groups, albums, etc.
052 const SCOPE_EDIT = 'edit';
053 // Delete videos, groups, albums, etc.
054 const SCOPE_DELETE = 'delete';
055 // Interact with a video on behalf of a user, such as liking
056 // a video or adding it to your watch later queue
057 const SCOPE_INTERACT = 'interact';
058 // Upload a video
059 const SCOPE_UPLOAD = 'upload';
060
061 public function __construct(
062 CredentialsInterface $credentials,
063 ClientInterface $httpClient,
064 TokenStorageInterface $storage,
065 $scopes = [],
066 ?UriInterface $baseApiUri = null
067 ) {
068 parent::__construct(
069 $credentials,
070 $httpClient,
071 $storage,
072 $scopes,
073 $baseApiUri,
074 true
075 );
076
077 if (null === $baseApiUri) {
078 $this->baseApiUri = new Uri('https://api.vimeo.com/');
079 }
080 }
081
082 /**
083 * {@inheritdoc}
084 */
085 public function getAuthorizationEndpoint()
086 {
087 return new Uri('https://api.vimeo.com/oauth/authorize');
088 }
089
090 /**
091 * {@inheritdoc}
092 */
093 public function getAccessTokenEndpoint()
094 {
095 return new Uri('https://api.vimeo.com/oauth/access_token');
096 }
097
098 /**
099 * {@inheritdoc}
100 */
101 protected function getAuthorizationMethod()
102 {
103 return static::AUTHORIZATION_METHOD_HEADER_BEARER;
104 }
105
106 /**
107 * {@inheritdoc}
108 */
109 protected function parseAccessTokenResponse($responseBody)
110 {
111 $data = json_decode($responseBody, true);
112
113 if (null === $data || !is_array($data)) {
114 throw new TokenResponseException('Unable to parse response.');
115 } elseif (isset($data['error_description'])) {
116 throw new TokenResponseException(
117 'Error in retrieving token: "' . $data['error_description'] . '"'
118 );
119 } elseif (isset($data['error'])) {
120 throw new TokenResponseException(
121 'Error in retrieving token: "' . $data['error'] . '"'
122 );
123 }
124
125 $token = new StdOAuth2Token();
126 $token->setAccessToken($data['access_token']);
127
128 if (isset($data['expires_in'])) {
129 $token->setLifeTime($data['expires_in']);
130 unset($data['expires_in']);
131 }
132 if (isset($data['refresh_token'])) {
133 $token->setRefreshToken($data['refresh_token']);
134 unset($data['refresh_token']);
135 }
136
137 unset($data['access_token']);
138
139 $token->setExtraParams($data);
140
141 return $token;
142 }
143
144 /**
145 * {@inheritdoc}
146 */
147 protected function getExtraOAuthHeaders()
148 {
149 return ['Accept' => self::HEADER_ACCEPT];
150 }
151
152 /**
153 * {@inheritdoc}
154 */
155 protected function getExtraApiHeaders()
156 {
157 return ['Accept' => self::HEADER_ACCEPT];
158 }
159 }
160