Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
breakoutModewide
languagephp
function getFormUrl($uuid, $email, $token)
{
    $api_url = "https://core.fairandsmart.com/api";
    $organisation_id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
    $model_id_or_alias = "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY";
    
    $host = $_SERVER['HTTP_HOST'];
    $port = "";
    $proto = isset($_SERVER['HTTPS']) ? "https" : "http";

    $email = in_array($email, explode(',', $config["authorized_emails"])) ? $email : null;
    $context = [
        "userid" => $uuid,
        "country" => "FR",
        "language" => "fr",
        "optoutEmail" => $email,
        "optoutEmailLink" => "https://mon-site/consentement",
    ];

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $api_url . "/organisations/" . $organisation_id . "/consents/" . $model_id_or_alias . "/endpoint");
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($context));
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("Authorization: Bearer $token", "Content-Type: application/json"));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);
}

...