[英]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表中獲取用戶名
$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 (點擊鏈接查看)。
嘗試在所有與用戶相關的調用中對用戶名進行URL編碼,例如:
$api->getUserPlaylist(urlencode('lillabjörn'), 'playlist_id');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.