forked from busybox11/NowPlaying-for-Spotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_EDIT_THIS_FILE.php
33 lines (25 loc) · 966 Bytes
/
token_EDIT_THIS_FILE.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
<?php
require 'vendor/autoload.php';
$session = new SpotifyWebAPI\Session(
'YOUR_CLIENT_ID',
'YOUR_CLIENT_SECRET',
'YOUR_DOMAIN'
);
if (!isset($_GET['action'])) {
$session->requestAccessToken($_GET['code']);
$accessToken = $session->getAccessToken();
setcookie('accessToken', $accessToken, time() + 3600);
setcookie('refreshTime', time() + 3600, time() + (3600 * 365));
$refreshToken = $session->getRefreshToken();
setcookie('refreshToken', $refreshToken, time() + (3600 * 365));
} elseif ($_GET['action'] == "refresh") {
$session->refreshAccessToken($_COOKIE['refreshToken']);
$accessToken = $session->getAccessToken();
setcookie('accessToken', $accessToken, time() + 3600);
setcookie('refreshTime', time() + 3600, time() + (3600 * 365));
$refreshToken = $session->getRefreshToken();
setcookie('refreshToken', $refreshToken, time() + (3600 * 365));
}
header('Location: playing.php');
die();
?>