Add unsubscribe page

This commit is contained in:
Sebastien Hattry 2021-07-08 15:34:00 +02:00
parent 2e9fefeb52
commit 4355cf50cf

View file

@ -1,23 +1,22 @@
<?php
// require_once 'wp-content/themes/reghalal/LDCCRM_V1.php';
// require_once 'vendor/autoload.php';
// Dotenv\Dotenv::createImmutable(__DIR__)->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.');
}