#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* spotifyToken = "BQBrMuf4f5EsGRFKbsrGozTZJejv6Y7ocx7HfK4Zci0w7XZSRMnKTiNKOrcT3bkKOChdnrhAbPZ9aFFVbsb7Ggc7y2ryQdujI6lDYQzzByxYwde5JFIbvfjVuCJ4MONRTLL1cWWFlVl1aO8YxqphcGduR5XAEWQw0gakJHfbQXMhLN8PFjtgz-d_AvdJNelSX8GwbXIjPhPqhBWWS4n3XTOkPVKgktGTq77n";
bool skipForward() {
HTTPClient http;
String url = "https://api.spotify.com/v1/me/player/next";
http.begin(url);
// Set authorization header
http.addHeader("Authorization", "Bearer " + String(spotifyToken));
// Set Content-Length header to 0
http.addHeader("Content-Length", "0");
// Send POST request
int httpResponseCode = http.POST("");
// Check if the request was successful
bool success = false;
if (httpResponseCode == HTTP_CODE_NO_CONTENT) {
Serial.println("Skipping forward");
success = true;
} else {
Serial.print("Error skipping forward. HTTP Status Code: ");
Serial.println(httpResponseCode);
String response = http.getString();
Serial.println(response);
}
// Disconnect from the Spotify API
http.end();
return success;
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Call skipForward function
skipForward();
}
void loop() {
// Nothing to do in the loop for this example
}