|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Class Foursquare |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://developer.foursquare.com/docs/ |
|
6
|
|
|
* @link https://developer.foursquare.com/overview/auth |
|
7
|
|
|
* |
|
8
|
|
|
* @filesource Foursquare.php |
|
9
|
|
|
* @created 10.08.2018 |
|
10
|
|
|
* @package chillerlan\OAuth\Providers\Foursquare |
|
11
|
|
|
* @author Smiley <[email protected]> |
|
12
|
|
|
* @copyright 2018 Smiley |
|
13
|
|
|
* @license MIT |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace chillerlan\OAuth\Providers\Foursquare; |
|
17
|
|
|
|
|
18
|
|
|
use chillerlan\OAuth\Core\OAuth2Provider; |
|
19
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
20
|
|
|
|
|
21
|
|
|
use function array_merge, explode, parse_str, parse_url; |
|
22
|
|
|
|
|
23
|
|
|
use const PHP_URL_QUERY; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @method \Psr\Http\Message\ResponseInterface me() |
|
27
|
|
|
*/ |
|
28
|
|
|
class Foursquare extends OAuth2Provider{ |
|
29
|
|
|
|
|
30
|
|
|
protected const API_VERSIONDATE = '20190225'; |
|
31
|
|
|
|
|
32
|
|
|
protected string $authURL = 'https://foursquare.com/oauth2/authenticate'; |
|
33
|
|
|
protected string $accessTokenURL = 'https://foursquare.com/oauth2/access_token'; |
|
34
|
|
|
protected ?string $apiURL = 'https://api.foursquare.com/v2'; |
|
35
|
|
|
protected ?string $userRevokeURL = 'https://foursquare.com/settings/connections'; |
|
36
|
|
|
protected ?string $endpointMap = FoursquareEndpoints::class; |
|
37
|
|
|
protected ?string $apiDocs = 'https://developer.foursquare.com/docs'; |
|
38
|
|
|
protected ?string $applicationURL = 'https://foursquare.com/developers/apps'; |
|
39
|
|
|
protected string $authMethodQuery = 'oauth_token'; |
|
40
|
|
|
protected int $authMethod = self::AUTH_METHOD_QUERY; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @inheritDoc |
|
44
|
|
|
*/ |
|
45
|
|
|
public function request( |
|
46
|
|
|
string $path, |
|
47
|
|
|
array $params = null, |
|
48
|
|
|
string $method = null, |
|
49
|
|
|
$body = null, |
|
50
|
|
|
array $headers = null |
|
51
|
|
|
):ResponseInterface{ |
|
52
|
|
|
|
|
53
|
|
|
parse_str(parse_url($this->apiURL.$path, PHP_URL_QUERY), $query); |
|
54
|
|
|
|
|
55
|
|
|
$query['v'] = $this::API_VERSIONDATE; |
|
56
|
|
|
$query['m'] = 'foursquare'; |
|
57
|
|
|
|
|
58
|
|
|
return parent::request(explode('?', $path)[0], array_merge($params ?? [], $query), $method, $body, $headers); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|