diff --git a/unsubscribe.php b/unsubscribe.php index 3dc1edc..30a6d05 100644 --- a/unsubscribe.php +++ b/unsubscribe.php @@ -1,23 +1,22 @@ load(); +require_once 'LDCCRM/ApiV1.php'; +require_once 'vendor/autoload.php'; +Dotenv\Dotenv::createImmutable(__DIR__)->load(); -// /* CRM */ -// define( 'CRM_TOKEN', getenv('CRM_API_TOKEN') ); -// define( 'CRM_ENDPOINT', getenv('CRM_ENDPOINT') ); +/* CRM */ +define( 'CRM_TOKEN', getenv('CRM_API_TOKEN') ); +define( 'CRM_ENDPOINT', getenv('CRM_ENDPOINT') ); if (!isset($_GET['hashcode']) || empty($_GET['hashcode'])) die('Missing fields.'); $hashcode = filter_var($_GET['hashcode'], FILTER_SANITIZE_STRING); -// $apiCrm = new \LDCCRM\ApiV1(CRM_ENDPOINT, CRM_TOKEN); +$apiCrm = new \LDCCRM\ApiV1(CRM_ENDPOINT, CRM_TOKEN); -$result = getApiCRM()->removeOptInCustomer($hashcode); -if ($result->status === "OK"){ - die('Vous avez été désabonné avec succès.'); -}else{ +$result = $apiCrm->removeOptInCustomer($hashcode); + +if ($result->status !== "OK"){ error_log("ERROR CRM API : $result->code - $result->message | hashcode : $hashcode"); die('Une erreur est survenue. Veuillez réessayer ultérieurement.'); }