Trying to get last entry from a thingspeak field into Arduino Uno

Hello everyone. I’m trying to get the last entry from a field into my Arduino Uno using ESP8266. So far, I’ve been able to use GET requests to send data to the channel but I have no idea on how I’m supposed to retrieve the same. Can somebody suggest a command to retrieve the last entry from a field?

Here’s my code:
#include<SoftwareSerial.h>

#define RX 10
#define TX 11

String AP = “XXXX”;
String PASS = “XXXXXXXX”;
String API = “XXXXXXXXX”;
String HOST = “api.thingspeak.com”;
String PORT = “80”;
String field1 = “field1”;
String field2 = “field2”;
String field3 = “field3”;

boolean a,b,c = 0;
boolean found = false;
int counttime;
int i;

SoftwareSerial esp8266(RX,TX);

void setup()
{
a = 0;
b = 1;

pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
Serial.begin(9600);
esp8266.begin(115200);

sendCommand(“AT”,5,“OK”);
sendCommand(“AT+CWMODE=1”,5,“OK”);
sendCommand(“AT+CWJAP=”"+ AP +"",""+ PASS +""",20,“OK”);
}

void loop()
{
// The status of the gate should be constantly updated in thingspeak. Need to read the status
// of fields 4 and 5 to obtain the user inputs.

c = !(a&b);

sendData(1); //update field 1. (input A)
sendData(2); //update field 2. (input B)
sendData(3); //update field 3. (output C)

}

void sendCommand(String command, int maxtime, char readReplay){
Serial.print("AT command is ");
Serial.println(command);

while(counttime<maxtime)
{
esp8266.println(command);
if(esp8266.find(readReplay))
{
found = true;
break;

}
counttime++;
}
if(found == true)
{
Serial.println(“Success.”);
counttime = 0;

}
if(found == false)
{
counttime = 0;
Serial.println(“Fail.”);
}

found = false;

}

void sendData(int x)
{
if(x==1)
{
String getData1 = “GET /update?api_key=”+ API +"&"+ field1 +"="+String(a);

sendCommand(“AT+CIPMUX=1”,5,“OK”);
sendCommand(“AT+CIPSTART=0,“TCP”,”"+ HOST +"","+ PORT,15,“OK”);

sendCommand(“AT+CIPSEND=0,” +String(getData1.length()+4),4,">");
esp8266.println(getData1);

delay(1500);
sendCommand(“AT+CIPCLOSE=0”,5,“OK”);
}
if(x==2)
{
String getData1 = “GET /update?api_key=”+ API +"&"+ field2 +"="+String(b);

sendCommand(“AT+CIPMUX=1”,5,“OK”);
sendCommand(“AT+CIPSTART=0,“TCP”,”"+ HOST +"","+ PORT,15,“OK”);

sendCommand(“AT+CIPSEND=0,” +String(getData1.length()+4),4,">");
esp8266.println(getData1);

delay(1500);
sendCommand(“AT+CIPCLOSE=0”,5,“OK”);
}
if(x==3)
{
String getData1 = “GET /update?api_key=”+ API +"&"+ field3 +"="+String(c);

sendCommand(“AT+CIPMUX=1”,5,“OK”);
sendCommand(“AT+CIPSTART=0,“TCP”,”"+ HOST +"","+ PORT,15,“OK”);

sendCommand(“AT+CIPSEND=0,” +String(getData1.length()+4),4,">");
esp8266.println(getData1);

delay(1500);
sendCommand(“AT+CIPCLOSE=0”,5,“OK”);

}
}