Can't create playlist for own user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I can't create a playlist for my own user
https://developer.spotify.com/documentation/web-api/tutorials/getting-started#request-artist-data
I always get
“status”: 403, “message”: “You cannot create a playlist for another user”
I can do other things, like get artist info.
I got the user ID from the profile page and it also what I get back from the PKCE example: https://github.com/spotify/web-api-examples/tree/master/authorization/authorization_code_pkce
This is my example code:
<?php
/* GET AUTHORIZATION */
$post = [
'grant_type' => 'client_credentials',
'scope' => 'playlist-modify-public playlist-modify-private',
];
$ch = curl_init('https://accounts.spotify.com/api/token');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic ' . base64_encode('{CLIENT_ID}:{CLIENT_SECRET}'),
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $post ) );
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode( $response, 1 );
/* ADD PLAYLIST */
$ch = curl_init('https://api.spotify.com/v1/users/{USER_ID}/playlists');
$playlist = json_encode( array( 'name' => 'Pandafish Test', 'description' => 'Testing the API', 'public' => 'true' ) );
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type:application/json',
'Authorization: Bearer ' . $response[ 'access_token' ],
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $playlist );
$playlist = curl_exec($ch);
curl_close($ch);
Thanks for having a look.
Kind regards,
Stijn
Labels:
- Labels:
-
Possible Bug
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page