Compare commits
2 commits
5cdc25ad9c
...
511841b9bf
Author | SHA1 | Date | |
---|---|---|---|
511841b9bf | |||
1457446bf8 |
1 changed files with 13 additions and 1 deletions
|
@ -32,6 +32,14 @@ function curlPost($url, $data, $headers = []) {
|
|||
|
||||
// === Create playlist helper ===
|
||||
function createPlaylist($accessToken) {
|
||||
|
||||
$path = __DIR__ . '/_credentials/fedilist_id.txt';
|
||||
|
||||
if (file_exists($path)) {
|
||||
echo "FediList Playlist ID already exists at :$path\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'snippet' => [
|
||||
'title' => 'FediList',
|
||||
|
@ -63,7 +71,7 @@ function createPlaylist($accessToken) {
|
|||
$result = json_decode($response, true);
|
||||
if (isset($result['id'])) {
|
||||
echo "FediList created!\nPlaylist ID: " . $result['id'] . "\n";
|
||||
file_put_contents(__DIR__ . '/_credentials/fedilist_id.txt', $result['id']);
|
||||
file_put_contents($path, $result['id']);
|
||||
} else {
|
||||
echo "Failed to create playlist:\n$response\n";
|
||||
}
|
||||
|
@ -84,6 +92,9 @@ echo "==== DEVICE AUTHORIZATION ====\n";
|
|||
echo "Visit: " . $deviceData['verification_url'] . "\n";
|
||||
echo "Enter code: " . $deviceData['user_code'] . "\n\n";
|
||||
|
||||
echo "Waiting...\n";
|
||||
|
||||
|
||||
// === Step 2: Poll for token ===
|
||||
$token = null;
|
||||
$startTime = time();
|
||||
|
@ -99,6 +110,7 @@ while (true) {
|
|||
|
||||
if (isset($tokenResponse['access_token'])) {
|
||||
$token = $tokenResponse;
|
||||
echo "Saving token.json\n";
|
||||
file_put_contents(__DIR__ . '/_credentials/token.json', json_encode($token));
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue