Add unsubscribe page
This commit is contained in:
parent
2e9fefeb52
commit
4355cf50cf
1 changed files with 10 additions and 11 deletions
|
|
@ -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.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue