-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMixcloud.php
51 lines (41 loc) · 1.48 KB
/
Mixcloud.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Class Mixcloud
*
* @created 28.10.2017
* @author Smiley <smiley@chillerlan.net>
* @copyright 2017 Smiley
* @license MIT
*/
declare(strict_types=1);
namespace chillerlan\OAuth\Providers;
use chillerlan\OAuth\Core\{AuthenticatedUser, OAuth2Provider, UserInfo};
/**
* Mixcloud OAuth2
*
* note: a missing slash at the end of the path will end up in a HTTP/301
*
* @link https://www.mixcloud.com/developers/
*/
class Mixcloud extends OAuth2Provider implements UserInfo{
public const IDENTIFIER = 'MIXCLOUD';
public const AUTH_METHOD = self::AUTH_METHOD_QUERY;
protected string $authorizationURL = 'https://www.mixcloud.com/oauth/authorize';
protected string $accessTokenURL = 'https://www.mixcloud.com/oauth/access_token';
protected string $apiURL = 'https://api.mixcloud.com';
protected string|null $userRevokeURL = 'https://www.mixcloud.com/settings/applications/';
protected string|null $apiDocs = 'https://www.mixcloud.com/developers/';
protected string|null $applicationURL = 'https://www.mixcloud.com/developers/create/';
/** @codeCoverageIgnore */
public function me():AuthenticatedUser{
// mixcloud sends "Content-Type: text/javascript" for JSON content (????)
$json = $this->getMeResponseData('/me/');
$userdata = [
'data' => $json,
'avatar' => $json['pictures']['extra_large'],
'handle' => $json['username'],
'url' => $json['url'],
];
return new AuthenticatedUser($userdata);
}
}