Customising the Consent modification link
It is possible to allow the user to receive by email a link allowing them to change the value of their consent.
By default, this link points directly to the consent iframe: the user clicking on the link will be redirected to the URL of the iframe, https://core.fairandsmart.com/api/consents/<serial>?t=<token>, which will be displayed without context elements.
As of version 20.11.01 (backend core v.5.2.0), it is possible to pass an arbitrary link that allows the consent iframe to be contextualised, for example by directing to the page on which the iframe is presented.
snippets are deliberately kept as simple as possible (no error checking, session management, etc. ).
Contents of this documentation:
Operating principle
It is assumed that the user is presented with the form via an iframe on the page https://mon-site /consent.
The idea is that the link in the email sent to the user takes the value of https://mon-site/consentement so when they click on it, they will be taken to the page allowing them to modify their consent.
If the user ID - userid parameter - is reused from one call to another, the form will be displayed with the replies previously given.
Kinematics
Once the integration has been carried out, the kinematics are as follows:
the user goes to the page presenting the consent iframe;
the backend presents them with a form set up in such a way as to:
send them an email;
containing the link to the page presenting the consent iframe;
the user submits their consent;
the user receives an email containing a link to the page with the consent iframe;
the user clicks on the link and is taken to the page with the consent iframe.
Obtaining a consent form URL
Based on the https://fairandsmart.atlassian.net/wiki/spaces/BDC/pages/960724997
/Int+integration+d+a+mod+the+consent#Obtention-d’une-URL-of-consent form; you modify the code so as to enter the email and URL:
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";
$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);
}
Regarding the HTML:
<html lang="fr">
<body>
<iframe src="<?php echo getFormUrl(getUserId(), getUserEmail(), getToken()) ?>" width="100%" name="consent"></iframe>
</body>
</html>
The code of the methods getUserId()
, getUserEmail()
, getToken()
is not explicit, but can for example retrieve the parameters in the URL ($_GET), in the session ($_SESSION), etc.
Source code
Find a more complete version of this code on github: https://github.com/fairandsmart/consent-iframe-integration- test