<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.asapp.com/conversation/v1/conversations/{conversationId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Hello, I would like to upgrade my internet plan to GOLD.',
'sender' => [
'role' => 'agent',
'externalId' => 123
],
'timestamp' => '2021-11-23T12:13:14.555Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"asapp-api-id: <api-key>",
"asapp-api-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}