Checking Thingspeak channel for updates

I created a thingspeak channel(feed) which monitors twitter streaming api for a trigger keyword. Every time a new tweet is posted with the trigger word my feed Channels - ThingSpeak IoT updated. I've got an arduino with an ethernet shield and I'm working on a sketch which sets a pin 13 high for 1 second when when a my feed receives a new update. However, i'm having issues in my loop. I start to get lost after client. available. Not sure how to parse results to see if there was an update. Here's where I'm at

void loop()
{
 
  if (client.available() > 0)
  {
    delay(100);
   
    String response;
    char charIn;
   
    do
    {
      charIn = client.read();
      response += charIn;  
    }
   
    while(client.available() > 0);
   
    if (response.indexOf("gumball") > 0)
    {  
        lastCommand = "gumball";
    }

I guess I'm just looking for some direction. I've mashed up a lot of different samples to get to this point and now I'm over my head. :roll_eyes:

Full sketch here

thingspeak api

Don't use the String class, it will fragment your memory in no time and sooner than later your Arduino crashed because it's out of memory. Try to change your sketch to use character arrays instead of the String class.

And get rid of the delay() calls. If you have a character available from the client you can process it immediately. Waiting for 0.1s is wasting too much time.

    do
    {
      charIn = client.read();
      response += charIn;  
    }
   
    while(client.available() > 0);

Wrong. A do/while loop will be executed at least once. You may (attempt to) read a non-existent character, and store garbage in your String. Use a while loop, instead.

As pylon says, the String class is unnecessary. You are not going to read that much data from the client. Create a static array to store data in. Using the string functions, not the String methods, to find data in the string.