Having problems setting up thingspeak

So this is my first arduino project and the first time I have touched code in 5 years so still learning most of the code. I have been trying to send data to Thingspeak but currently have been unable to. Here is the code and any suggestions on where I went wrong would be greatly appreciated.

#include <OneWire.h>   //one wire DO sesnor
#include <DallasTemperature.h>
#include "RTClib.h"
#include <Wire.h> // Helps with i2c
#include <ccspi.h>
#include <string.h>
#include "utility/debug.h"
#include <Adafruit_CC3000.h>
#include <ccspi.h>

#define DS18B20 2 //the pin you connect the ds18b20 to
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed but DI
                                         
OneWire ourWire(DS18B20);
DallasTemperature sensors(&ourWire);

#define WLAN_SSID       "Dreddit"        // cannot be longer than 32 characters!
#define WLAN_PASS       "loxg1493"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

const int chipSelect = 10;


char thingSpeakAddress[] = "api.thingspeak.com";
String APIKey = "2EBZ76PBJWYEWN91";              //enter your channel's Write API Key
//const int updateThingSpeakInterval = 20 * 1000;  // 20 second interval at which to update ThingSpeak

long lastConnectionTime = 0;
boolean lastConnected = false;

uint32_t ip;

void setup() {
  
Serial.begin(115200);
sensors.begin();
Wire.begin();
pinMode(10, OUTPUT); //OUTPUT FOR DATA LOGGER
cc3000.begin();

  char *ssid = WLAN_SSID;             /* Max 32 chars */
  Serial.print(F("\nAttempting to connect to ")); Serial.println(ssid);
  
if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
   
  Serial.println(F("Connected!"));
Serial.println(sensors.getTempCByIndex(0));

Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }  
  while (! displayConnectionDetails()) {
    delay(1000);
  }
}
void loop() {


sensors.requestTemperatures(); // Send the command to get temperatures

String temp = String(sensors.getTempCByIndex(0), DEC);
Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);

  Serial.println(temp);
    updateThingSpeak("field1=" + temp); 
    Serial.println(sensors.getTempCByIndex(0));

delay(20);

 
}
void updateThingSpeak(String tsData) {

  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);

  
  if (client.connect(thingSpeakAddress, 80)) {
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + APIKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(tsData.length());
    client.print("\n\n");
    client.print(tsData);
    //lastConnectionTime = millis();

    if (client.connected()) {
      Serial.println("Connecting to ThingSpeak...");
      Serial.println();
    }
  }
}
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}