doukun8944
doukun8944
2016-10-09 15:42
浏览 38
已采纳

PHP致命错误/ Spotify Web Api

My script runs into an error - can someone help me on this? For me it looks like, that something is not okay with the username?

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

I think it is this line ->

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

I get the username from a mysql table like this

$USERPL = $pl['user_name'];

Would be great if some can give me some help.

图片转代码服务由CSDN问答提供 功能建议

我的脚本遇到错误 - 有人可以帮我吗? 对我来说,看起来,用户名不合适?

  PHP致命错误:未捕获异常'SpotifyWebAPI \\ SpotifyWebAPIException',并显示消息'发生未知错误'。 在/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-&gt; parseBody('&lt; html&gt;&lt; body&gt;&lt; h1 ...',400)
#3 / mnt / webp / b3 / 44/5462244 / htdocs /  SpotifyTest / testfile.php(68):SpotifyWebAPI \\ SpotifyWebAPI-&gt; getUserPlaylist('lillabj \\ xC3 \\ xB6rn','0WXsElmPC8aEGzr ...')
#4 {main} 
thrown在/ mnt / webp /  b3 / 44/5462244 / htdocs / SpotifyTest / src / Request.php第38行
   
 
 

我认为是这一行 - &gt;

 <代码> SpotifyWebAPI-&GT; getUserPlaylist( '** llabj \\ XC3 \\ xB6rn **',... 
   
 
 

我从这样的mysql表中获取用户名

  $ USERPL = $ pl ['user_name']; 
   
 
 < 如果有些人可以给我一些帮助,那会很棒。 
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doudao9915
    doudao9915 2016-10-10 04:20
    已采纳

    I think the problem is related to special characters in the username, the \\xC3\\xB6 part should be an "ö" so the full username is "lillabjörn".

    When you run another user request with the same username in the Spotify Web API Console you can see that it's URL encoded in the actual request sent, https://developer.spotify.com/web-api/console/get-users-profile/?user_id=lillabj%C3%B6rn (click the link to see it).

    Try URL encoding the username in all user related calls, for example:

    $api->getUserPlaylist(urlencode('lillabjörn'), 'playlist_id');
    
    点赞 评论

相关推荐