But I intend that BOTtoken be a global String because I will inform the code later, sending it through .txt file
I'm using a espcam that takes a picture and sends it to telegram.
But it doesn't work because Telegram responds as unauthorized access because when initializing the code, the String BOTtoken is empty first.
It will only be 'filled' when the code goes to setup() because there it will read the String from a file stored in SPIFFS.
It is not a question of analyzing a code, but a theoretical question. How to inform at initialization a value of a String that will only be read in setup() ?
Can at least understand the problem after dozens of tests.
It's not what I wrote in post#1
The problem is the following:
If I try to read the fields strings[4] and strings[5] of the code snippet below, coming from inside the CONFIG.txt file that is in SPIFFS where i have 6 fields separated by comma, I can't connect to the Telegram BOT.
But if I enter the values (see just below), then it works.
So my little knowledge tells me that the read is not bringing a String. Therefore I tried converting using String(strings[4]);
Not knowing what was happening, I created a second .txt file called BOT and saved it inside SPIFFS. In it I only put the BOT Telegram code, note that I fill the String BOTtoken with it. And this String is declared as a global String.
That's not what you're giving it. Not sure there's a solution with that library for what you want to do. Maybe mod it so that it is just looking for a string. Beyond my pay grade.
I got an example code that sends a photo to a Telegram BOT (espcam). I'm just wanting to inform the BOTToken String by the WebServer doing UPLOAD of the .txt file. The code reads in setup() and assigns the value to the BOTtoken global String. It doesn't work, it gives a 401 error. But if I type the value of the String BOTtoken, it works.