hi all
I'm trying to connect to the rahpay server (payment) using ESP8266 and the Arduino nano. But so far with no result.
and problem to get 307 redirect !
get message :
HTTP/1.1 307 Temporary Redirect
Server: ArvanCloud
Date: Mon, 06 Apr 2020 20:05:56 GMT
Content-Type: text/html
Content-Length: 0
Connection: keep-alive
Location: /qr_announcement
Set-Cookie: __acsco=54e885c6eedce963544182ec70a13371; Path=/; HttpOnly; Max-Age=1000; Domain=rahpay.net
AR-PoweredBy: Arvan Cloud (arvancloud.com)
AR-ATIME: 0.136
AR-Request-ID: 326872962ab897c4b797b902a3c3c737
and code : URL=/qr_announcement
String GetToken(String URL) {
String title = "";
String headers = "";
String body = "";
bool finishedHeaders = false;
bool currentLineIsBlank = true;
bool gotResponse = false;
long now;
char host[] = "core.rahpay.net";
espClient.setInsecure();
if (espClient.connect(host, 443)) {
Serial.println("connected");
Serial.println(URL);
espClient.println("POST " + URL + " HTTP/1.1");
espClient.print("Host: ");
espClient.println(host);
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
//espClient.print("Content-Type: application/form-data\n");
espClient.println("User-Agent: arduino/1.0");
espClient.println("");
now = millis();
// checking the timeout
while (millis() - now < 1500) {
while (espClient.available()) {
char c = espClient.read();
Serial.print(String(c));
if (finishedHeaders) {
body = body + c;
} else {
if (currentLineIsBlank && c == '\n') {
finishedHeaders = true;
}
else {
headers = headers + c;
}
}
if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
//marking we got a response
gotResponse = true;
}
}
}
but this redirect must automaticaly handle ! and browsers engine handle this problem but my arduino stop this segment
sorry for type....