summaryrefslogtreecommitdiff
path: root/lib/sounds-auth.php
blob: 91e259909427efcc303deb99d92fe7131a0cc5ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

// where does 1d590d3 come from? i have no clue
const SOUNDS_NEXT_DATA_BASE = 'https://www.bbc.co.uk/sounds/_next/data/1d590d3';
const SOUNDS_NEXT_DATA_LIVE = '/play/live/{service}.json';

function sounds_fetchPageData(string $path) {
    return json_decode(file_get_contents(SOUNDS_NEXT_DATA_BASE . $path));
}

function sounds_getLiveBearerToken(string $service) {
    return sounds_fetchPageData(
        str_replace('{service}', $service, SOUNDS_NEXT_DATA_LIVE)
    )->pageProps->jwtToken;
}