Comment pouvons nous vous aider ? 👋

API createAccount

1. Code to use

<?php
    // ================================================================================
    // DATA PREPARATION
    // ================================================================================
    $post_data = array();
    // ---------------------------- Profile attributes -------------------------------
    $post_data["data"]["customer_email"] = "john@doe.com";
    $post_data["data"]["external_id"] = "12345xxx6789";
    if (isset($_COOKIE['sbt'])) // Save the customer's authentication cookie if it is present.
    {
       $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"); // Adding customer tags
    $post_data["data"]["del_tag"] = array("tag3", "tag4"); // Removal of customer tags
    $post_data["data"]["action"] = "order";
    // Custom fields
    $post_data["data"]["custom_fields"][327] = "value"; // ID of the custom_field to be found in your BackOffice, at the bottom of "Intégration > Tracker > Intégration > Exemple de codes".
 

    // ================================================================================
    // CURL CALL
    // ================================================================================
    $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"); // To be replaced by your public and private API keys in your back office, menu "Integration > Tracker"
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $curl_return = curl_exec($curl);
    curl_close($curl);
 ?>

2. Explications

Connect the site with the SPREAD BackOffice

In the CURL call at the end of the code, insert your public and private API keys. You can find them in your BackOffice, tab Intégration > Tracker.

 

Profile attributes

Notion image
 

Custom Fields

You can add more information to SPREAD profiles by creating custom fields. These can be filled in different ways and you can upload information to them in PHP.

To do this, use $post_data["data"]["custom_fields"][327] = "value";

327 is a custom field identifier here, find yours at the bottom of this page.

 

Newsletter Subscription

Newsletter subscriptions require the profile email address.

In SPREAD, each consent has a technical ID that you can customize.

You can retrieve the newsletter and SMS subscriptions with these settings:

  • customer_isoptin
  • customer_mobile_isoptin
 
 
🆘
If you have any further questions about this topic, you can contact support. 💬
Cela a-t-il répondu à votre question ?
😞
😐
🤩