From 159a0fb6dad47d3790ed23f1fa5853c3df728799 Mon Sep 17 00:00:00 2001 From: u230412 Date: Thu, 30 Dec 2021 10:39:56 +0100 Subject: [PATCH] #1309, #1451, #1691 Add user-agent to avoid 400-bad-requests from open.spotify.com. --- htdocs/inc.viewFolderTree.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/inc.viewFolderTree.php b/htdocs/inc.viewFolderTree.php index b40e26657..d46ace944 100755 --- a/htdocs/inc.viewFolderTree.php +++ b/htdocs/inc.viewFolderTree.php @@ -116,18 +116,19 @@ // this is a new and easier way for loading spotify informations! $uri = file_get_contents($subfolder."/spotify.txt"); $url = "https://open.spotify.com/oembed/?url=".trim($uri)."&format=json"; + $headers = stream_context_create(array('http'=>array('method'=>'GET', 'header'=>'user-agent:Phoniebox'))); if (!file_exists($coverfile)) { - $str = file_get_contents($url); + $str = file_get_contents($url, false, $headers); $json = json_decode($str, true); $cover = $json['thumbnail_url']; - $coverdl = file_get_contents($cover); + $coverdl = file_get_contents($cover, false, $headers); file_put_contents($coverfile, $coverdl); } if (!file_exists($titlefile)) { - $str = file_get_contents($url); + $str = file_get_contents($url, false, $headers); $json = json_decode($str, true); $title = $json['title'];