feat(spotify): add connection to get token
This commit is contained in:
parent
dd9b054b33
commit
1ff4d8a02a
4 changed files with 26 additions and 1 deletions
|
@ -1 +1,5 @@
|
|||
Site pour pouvoir vérifier si un artiste présent sur Spotify possède un compte bandcamp.
|
||||
|
||||
Pour configurer le fichier `config.go`:
|
||||
* ClientID: l’id de votre application
|
||||
* RedirectURI: lien de redirection après l’authentification
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
package main
|
||||
|
||||
var SpotifyAPI = "test"
|
||||
var SpotifyAPI = ""
|
||||
var ClientID = ""
|
||||
var RedirectURI = ""
|
||||
|
|
17
server.go
17
server.go
|
@ -15,6 +15,17 @@ import (
|
|||
var MyClient = &http.Client{}
|
||||
var MyResp = &RespBandcamp{}
|
||||
|
||||
func loginSpotify(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
fmt.Fprintf(w, "ParseForm() err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Location", "https://accounts.spotify.com/authorize?client_id="+ClientID+"&response_type=token&redirect_uri="+RedirectURI)
|
||||
w.WriteHeader(http.StatusSeeOther)
|
||||
go getListPlaylist(r.FormValue("id"))
|
||||
}
|
||||
|
||||
/*
|
||||
check artist and album
|
||||
items[x].track.album.name et items[x].track.album.artists[0].name
|
||||
|
@ -216,12 +227,18 @@ func getNew(w http.ResponseWriter, r *http.Request) {
|
|||
MyResp.Notfound = nil
|
||||
}
|
||||
|
||||
func mytest(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, r.RequestURI)
|
||||
}
|
||||
|
||||
func main() {
|
||||
fileServer := http.FileServer(http.Dir("./static"))
|
||||
http.Handle("/", fileServer)
|
||||
http.HandleFunc("/hello", hello)
|
||||
http.HandleFunc("/back", formHandler)
|
||||
http.HandleFunc("/refresh", getNew)
|
||||
http.HandleFunc("/spotify", loginSpotify)
|
||||
http.HandleFunc("/mytest", mytest)
|
||||
|
||||
fmt.Printf("Starting the server…\n")
|
||||
if err := http.ListenAndServe(":8080", nil); err != nil {
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<p>Recherche dans une playlist les artistes se trouvant aussi sur Bandcamp !</p>
|
||||
<hr />
|
||||
|
||||
<a href="/spotify">SE CONNECTER À SPOTIFY ICI</a>
|
||||
|
||||
<div>
|
||||
<form action="/back" method="post">
|
||||
<label>Saisir l’ID de la playlist (sans l’url): <input name="id" type="text" required /></label> <br />
|
||||
|
|
Loading…
Reference in a new issue