-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvancedUsage.ino
More file actions
40 lines (30 loc) · 991 Bytes
/
AdvancedUsage.ino
File metadata and controls
40 lines (30 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <GenericHTTP.h>
const char* SSID = "your_wifi_ssid";
const char* PASSWORD = "your_wifi_password";
GenericHTTP http;
void setup() {
Serial.begin(9600);
while (!Serial); // Wait for Serial Monitor to open
// Initialize the "GenericHTTP" library and connect to Wi-Fi
http.connectToWiFi(SSID, PASSWORD);
}
void loop() {
// Set custom headers
const char* customHeaders = "Authorization: Bearer YOUR_ACCESS_TOKEN\r\n";
// Send an HTTP GET request with custom headers
bool success = http.sendHTTPRequest("GET", "example.com", "80", "/path/to/endpoint", customHeaders, nullptr);
if (success) {
Serial.println("Request successful!");
// Read and parse the response data
String response;
while (http.espSerial.available()) {
char c = http.espSerial.read();
response += c;
}
Serial.println("Response: " + response);
// Process the response data here
} else {
Serial.println("Request failed!");
}
delay(5000);
}