mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-26 23:45:49 +03:00
[GH-ISSUE #224] Malformed JSON error when using play #158
Labels
No labels
bug
docs
enhancement
enhancement
enhancement
feedback wanted
good first issue
help wanted
help wanted
help wanted
invalid
pull-request
question
question
upstream
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-web-api-php#158
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ericlove02 on GitHub (Mar 2, 2021).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/224
I am getting this error when I try and use the Play endpoint:
Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIException: Malformed json in D:\wamp64\www\vendor\jwilsson\spotify-web-api-php\src\Request.php on line 57
My code:
`<?php
require '../vendor/autoload.php';
$api = new SpotifyWebAPI\SpotifyWebAPI();
session_start();
$api->setAccessToken($_SESSION['token']);
$api->play($_SESSION['playback_device']);`
I am using the same code (with the endpoint change of course) for pause, next, and previous and am having no problems. Any ideas?
@jwilsson commented on GitHub (Mar 2, 2021):
Hey!
Spotify no longer seems to like an empty
$optionsbeing sent. Passingnullseems to be a workaround until I can get a fix out. For example:Hope that solves it for you!
@ericlove02 commented on GitHub (Mar 2, 2021):
Thanks for the idea. I tried that and now I am getting a new error:
Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIException: Server error. in D:\wamp64\www\vendor\jwilsson\spotify-web-api-php\src\Request.php on line 57
@ericlove02 commented on GitHub (Mar 2, 2021):
It works correctly when I pass a uri, for example:
$api->play($_SESSION['playback_device'], ['uris'=>['spotify:track:5QO79kh1waicV47BqGRL3g']]);
but it does not like:
$api->play($_SESSION['playback_device'], null);
@jwilsson commented on GitHub (Mar 2, 2021):
Hmm, I can't think of anything more right now (unless you're fine with always passing a URI). I'll try and get a fix out ASAP.
@ericlove02 commented on GitHub (Mar 2, 2021):
Yeah, I couldn't get it working without passing a uri, so for my application I ended up doing this:
$trackUri = "spotify:track:" . $_GET['id'];
$position = $_GET['pos'];
$api->play($_SESSION['playback_device'], ['uris'=>[$trackUri], 'position_ms'=>$position]);
@jwilsson commented on GitHub (Mar 2, 2021):
I just published
4.2.2which should solve the issue.Let me know if it doesn't!