【问题标题】:PHP Fatal Error / Spotify Web ApiPHP 致命错误 / Spotify Web Api
【发布时间】:2016-10-09 15:42:43
【问题描述】:

我的脚本出错了 - 有人可以帮我解决这个问题吗?对我来说,用户名似乎有问题?

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'];

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

【问题讨论】:

  • 坏消息:你在 mysql 中存储垃圾。 lillabjörn 应该按原样存储,而不是作为 llabj\\xC3\\xB6rn 奇怪编码的东西

标签: php spotify


【解决方案1】:

我认为问题与用户名中的特殊字符有关,\\xC3\\xB6 部分应该是“ö”,所以完整的用户名是“lilabjö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');

【讨论】:

    猜你喜欢
    • 2018-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    • 2023-03-13
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多