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