Hi
I’m having a play with Active Campaign API, trying to pass along form data from my website into Active Campaign via the API.
I’ve created a test form in Active Campaign, with two fields fullname
and email
. My website form has the same fields, with the same IDs.
I need some help with the syntax in Laravel
public function handle(FormSubmitted $event)
{
// Log::debug(serialize($event));
// return false;
if ($event->submission->form->handle() == 'newsletter') {
$client = new Client();
$result = Http::withHeaders([
'Api-Token' => 'xxxxxxxx33bb10b0b30',
])->post('https://xxxxx86046357.api-us1.com/api/3/forms/id', [
'fullname' => $event->submission->fullname,
'email' => $event->submission->email,
]);
if ($result->getStatusCode() === 200) {
return false;
} else {
throw \Illuminate\Validation\ValidationException::withMessages(['API call failed']);
}
}
}