'rate limited']); exit; } $api_key = lastfm_api_key(); $user = 'SillyLaird'; $url = "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user={$user}&api_key={$api_key}&format=json&limit=5"; $ctx = stream_context_create(['http' => [ 'timeout' => 5, 'header' => 'User-Agent: www.sillylaird.ca/1.0', ]]); $response = @file_get_contents($url, false, $ctx); if ($response === false) { http_response_code(502); echo json_encode(['error' => 'Failed to fetch from Last.fm']); exit; } // Cap response size we relay back (defensive — Last.fm responses are tiny). if (strlen($response) > 256 * 1024) { $response = substr($response, 0, 256 * 1024); } echo $response;