summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rms.php1
-rw-r--r--lib/sounds-auth.php12
2 files changed, 3 insertions, 10 deletions
diff --git a/lib/rms.php b/lib/rms.php
index 8b92e49..ab0fd71 100644
--- a/lib/rms.php
+++ b/lib/rms.php
@@ -4,6 +4,7 @@ const RMS_API_BASE = 'https://rms.api.bbc.co.uk/v2';
const RMS_SOUNDS_HOME = '/experience/inline/listen/sign-in';
const RMS_SOUNDS_CONTAINER = '/experience/inline/container';
const RMS_SOUNDS_PLAYABLE = '/experience/inline/play';
+const RMS_SOUNDS_TOKEN_BASE = '/sign/token';
function rms_fetch(string $path): stdClass {
return json_decode(file_get_contents(RMS_API_BASE . $path));
diff --git a/lib/sounds-auth.php b/lib/sounds-auth.php
index 91e2599..9a333bf 100644
--- a/lib/sounds-auth.php
+++ b/lib/sounds-auth.php
@@ -1,15 +1,7 @@
<?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));
-}
+require_once __DIR__ . '/rms.php';
function sounds_getLiveBearerToken(string $service) {
- return sounds_fetchPageData(
- str_replace('{service}', $service, SOUNDS_NEXT_DATA_LIVE)
- )->pageProps->jwtToken;
+ return rms_fetch(RMS_SOUNDS_TOKEN_BASE . "/$service")->token;
}