-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: Uncaught exception on page refresh #52
Comments
Hi! One page (let's call it In |
Awesome, thank you for your help! I've got it working, I think. Storing the $accessToken within a session variable and recalling it on index.php worked. |
Hi ! I'm sorry, I'm not sure I understand this page : https://jwilsson.github.io/spotify-web-api-php/authorization.html Here is my code, would appreciate some help :) in ./index.php :
then in ./callback/index.php :
What happens is that if I go to https://mysite.com/ I immediately get redirected to https://mysite.com/callback?code=XXXXXXX and the result that I want is displayed. However if I refresh, I get this uncaught exception. Could you please help me to understand your authorization doc page ? thanks ! |
@hycday Instead of printing the history in In Sloppy, untested example using PHP sessions: https://gist.github.com/jwilsson/07f30721b5a3378c78bf4c86cdc92b98 I can agree that the docs could be more clear, though. I'll look at updating it. |
thank you @jwilsson |
just out of curiosity, I managed to do it in PHP session (then each user will see their own tracks), but when I do it with a database, I am facing a problematic : they all see my tracks. Indeed, in the database, (in which I have a token field, a timestamp field, and a userid field), I need to insert a row with a token (or update it for same userid, if timestamp is expired and userid exists), but I just used a fake userid manually inputed, so therefore, their is only one user, and hence they all see my tracks. Is there a function to identify the user via some sort of ID, proper to Spotify ? or basically the database approach is not applicable ? If I remove the userid field, how will I know which token to retrieve from the database, for each user... Do you see what I mean ? |
@hycday Let's not hijack this issue anymore, drop me a line at |
Hi, I am getting the following error when I refresh my Spotify web app...
Fatal error: Uncaught exception 'SpotifyWebAPI\SpotifyWebAPIException' with message 'Invalid authorization code' in /Users/user/Desktop/WEB-DEV/spotify-web-api-php-master/src/Request.php:170 Stack trace: #0 /Users/user/Desktop/WEB-DEV/spotify-web-api-php-master/src/Request.php(50): SpotifyWebAPI\Request->send('POST', 'https://account...', Array, Array) #1 /Users/user/Desktop/WEB-DEV/spotify-web-api-php-master/src/Session.php(205): SpotifyWebAPI\Request->account('POST', '/api/token', Array, Array) #2 /Users/user/Desktop/WEB-DEV/spotify-web-api-php-master/includes/api-key.php(4): SpotifyWebAPI\Session->requestAccessToken('AQAaKVCyJ2eX1vE...') #3 /Users/user/Desktop/WEB-DEV/spotify-web-api-php-master/index.php(20): include('/Users/user/Des...') #4 {main} thrown in /Users/user/Desktop/WEB-DEV/spotify-web-api-php-master/src/Request.php on line 170
I think the reason for this error is because the URL has the code from Spotify as a query string on the end. If I delete everything from ?code onwards and reload the page it works fine. I just cant figure out how to not display the query string on the URL but keep the app working.
My code is as follows...
Thanks
The text was updated successfully, but these errors were encountered: