Created
September 8, 2018 03:46
-
-
Save MatthewStanciu/cecc79f4654ee455cf0265b5015a70c0 to your computer and use it in GitHub Desktop.
Post a new song to our collaborative spotify playlist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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