繁体   English   中英

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表中获取用户名

$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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM