Skip to content

Instantly share code, notes, and snippets.

@MatthewStanciu
Created September 8, 2018 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewStanciu/cecc79f4654ee455cf0265b5015a70c0 to your computer and use it in GitHub Desktop.
Save MatthewStanciu/cecc79f4654ee455cf0265b5015a70c0 to your computer and use it in GitHub Desktop.
Post a new song to our collaborative spotify playlist
app.post('/song', function(req, res) {
refresh(process.env.REFRESH_TOKEN, process.env.CLIENT_ID, process.env.CLIENT_SECRET, function(err, res, body) {
if (err) return err;
request.post({
url: 'https://api.spotify.com/v1/playlists/your-playlist-id/tracks?uris=spotify%3Atrack%3A' +
getIDfromUrl(req.body.submiturl),
headers: {
'Authorization': 'Bearer ' + body.access_token,
'Host': 'api.spotify.com',
'Accept': 'application/json',
'Content-Type': 'application/json'
},
json: true
});
});
console.log("added " + req.body.submiturl + " to the playlist");
res.redirect("/added");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment