3

My aim is getting the album and its cover image with a given string like "Artist Name - Song Name". For that, I use Spotify Web API and I guess it doesn't require OAuth for these kinds of requests.

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.spotify.com/v1/search?q=".$query."&type=track");
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$data=curl_exec($ch);
curl_close($ch);
echo $data;

If you click the following link, you can get the JSON but this request returns me an error page. I've tried with Ajax as well but nothing changed. Can somebody help me about that?

1
  • 400 Bad request Your browser sent an invalid request. 1 Commented May 1, 2015 at 15:17

1 Answer 1

2

You should urlencode() your query before sending it to Spotify, otherwise you will get a 400 Bad Request response.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.