PHP 致命错误/Spotify Web Api

PHP Fatal Error / Spotify Web Api

我的脚本遇到错误 - 谁能帮我解决这个问题?对我来说,用户名好像有问题?

PHP Fatal error:  Uncaught exception 'SpotifyWebAPI\SpotifyWebAPIException' with message 'An unknown error occurred.' in /mnt/webp/b3/44/5462244/htdocs/SpotifyTest/src/Request.php:38
Stack trace:
#0 /mnt/webp/b3/44/5462244/htdocs/SpotifyTest/src/Request.php(188): SpotifyWebAPI\Request->parseBody('<html><body><h1...', 400)
#3 /mnt/webp/b3/44/5462244/htdocs/SpotifyTest/testfile.php(68): SpotifyWebAPI\SpotifyWebAPI->getUserPlaylist('lillabj\xC3\xB6rn', '0WXsElmPC8aEGzr...')
#4 {main}
thrown in /mnt/webp/b3/44/5462244/htdocs/SpotifyTest/src/Request.php on line 38

我认为是这一行 ->

SpotifyWebAPI->getUserPlaylist('**llabj\xC3\xB6rn**',.....

我从 mysql table 中获取用户名

$USERPL = $pl['user_name'];

如果有人能给我一些帮助就太好了。

我认为问题与用户名中的特殊字符有关,\xC3\xB6 部分应该是“ö”,所以完整的用户名是 "lillabjörn"。

当您 运行 另一个用户在 Spotify Web API 控制台中使用相同的用户名请求时,您可以看到它是 URL 在发送的实际请求中编码的,https://developer.spotify.com/web-api/console/get-users-profile/?user_id=lillabj%C3%B6rn(点击link查看)。

尝试 URL 在所有与用户相关的调用中对用户名进行编码,例如:

$api->getUserPlaylist(urlencode('lillabjörn'), 'playlist_id');