Skip to content

Instantly share code, notes, and snippets.

@spreadfamily
Created March 9, 2020 10:02
<?php
// ================================================================================
// PREPARATION DES DONNEES
// ================================================================================
$post_data = array();
// ---------------------------- Attributs du profil -------------------------------
$post_data["data"]["customer_email"] = "john@doe.com";
$post_data["data"]["external_id"] = "12345xxx6789";
if (isset($_COOKIE['sbt'])) // Sauvegarde du cookie d'authentification du customer s'il est présent.
{
$post_data["data"]["customer_cookie"] = $_COOKIE['sbt'];
}
$post_data["data"]["customer_name"] = "Doe";
$post_data["data"]["customer_firstname"] = "John";
$post_data["data"]["customer_isoptin"] = "1"; // 1:optin / 0:not optin / -1: unknown
$post_data["data"]["customer_gender"] = "male"; // "male" or "female"
$post_data["data"]["customer_address"] = "8, rue de la place";
$post_data["data"]["customer_address2"] = "bâtiment A";
$post_data["data"]["customer_address3"] = "appartement 23";
$post_data["data"]["customer_cp"] = "76000";
$post_data["data"]["customer_city"] = "Rouen";
$post_data["data"]["customer_country"] = "FR";
$post_data["data"]["customer_tel"] = "0235000000";
$post_data["data"]["customer_mobile"] = "060606606";
$post_data["data"]["customer_fonction"] = "developer";
$post_data["data"]["customer_company"] = "SPREAD";
$post_data["data"]["customer_birthday"] = "1970-12-31";
$post_data["data"]["customer_lang"] = "fr_FR";
$post_data["data"]["add_tag"] = array("tag1", "tag2"); // Ajout de tags client
$post_data["data"]["del_tag"] = array("tag3", "tag4"); // Suppression de tags client
$post_data["data"]["action"] = "signup";
// Champs personnalisés
$post_data["data"]["custom_fields"][327] = "value"; // ID du custom_field à retrouver dans votre BackOffice, en bas de "Paramétrage > Tracker > Exemple de codes".
// ================================================================================
// APPEL CURL
// ================================================================================
$curl_post_data = http_build_query($post_data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://social-sb.com/api/createAccount");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_USERPWD, "PUBLIC_KEY:PRIVATE_KEY"); // À remplacer par vos clés d'API publique et privée dans votre back office, menu "Paramétrage > Tracker" en bas de page
curl_setopt($curl, CURLOPT_POSTFIELDS,$curl_post_data );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_return = curl_exec($curl);
curl_close($curl);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment