Timeout when creating Timeline API Event



Relatively new to the API and just require a little clarification.

I am creating an app which creates a timeline event each time a customer makes a purchase on the clients website.

I have Oauth working properly and have created the event type and properties however when i try and create the event on a timeline the script times out and eventually throws a 500 response, below is the script i am using. Any suggestions here would be greatly appreciated. I have a feeling it may have something to do with the headers but cannot work it out. TIA

$hubSpotData = array(
‘id’ => ‘101124’,
‘eventTypeId’ => ‘17725’,
‘orderTotal’ => ‘$1234.00’,
‘SKUS’ => ‘plier14323’,
‘email’ => $email
$post_json = json_encode($hubSpotData);

$headers = array();
$headers[] = ‘Content-Type: application/json’;
$headers[] = 'Authorization: Bearer ’ .$dbToken[‘access_token’];
$headers[] = 'Content-Length: ’ . strlen($post_json);

$endpoint = ‘https://api.hubapi.com/integrations/v1/40168/timeline/event’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_json);
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($ch), true);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errors = curl_error($ch);