Hello! I’m new in Mautic and I’m having some trouble trying to understand how to do the requests on the API.
When the user enter in my page, the authentication begins and I receive the access_token normally.
Later, I created another file( invitation.php) which is responsible for create a new contact inside Mautic.
This invitation, I call with AJAX from JS.
include_once __DIR__ . '/mauticapi/vendor/autoload.php'; use MauticMauticApi; $data = array( 'firstname' => '', 'lastname' => '', 'email' => $_POST['email'], 'ipAddress' => $_SERVER['REMOTE_ADDR'] ); $api = new MauticApi(); $contactApi = $api->newApi('contacts', $auth, $apiUrl); $contact = $contactApi->create($data);
The problem is that I loose the reference to $auth.
Could someone explain me the better way to do this?
Thanks so much!