Connection Make an appointment Make an appointment Free trial
Login

How do I insert data into a contact list with the Mailify API?

There are a variety of methods but we have chosen an example using an HTML form that will be used to send data to your contact list. Below is an example of a form with an email field to be filled in:

     <form action="" method="POST">       <input type="text" placeHolder="Email" name="email" />       <input type="text" placeHolder="Apellido" name="nom" />       <input type="text" placeHolder="Nombre" name="prenom" />       <input type="submit">   </form> 

Let's switch to data processing with the Mailify API.

To use the Mailify API, firstly you have to check that the "php_curl" extension be enabled in your PHP setup. (archivo php.ini)


Step 1 - Copy the code


As some specific data is similar each time the API is called, copy this PHP function at the beginning of the file so as to create your start string and connect to the API more easily.

<?php    function post_to_url($url, $data) {    $fields = '';    foreach($data as $key => $value) {       $fields .= $key . '=' . $value . '&';    }    rtrim($fields, '&');     $post = curl_init();    curl_setopt($post, CURLOPT_URL, $url);    curl_setopt($post, CURLOPT_POST, count($data));    curl_setopt($post, CURLOPT_POSTFIELDS, $fields);    curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);     $result = curl_exec($post);     curl_close($post); }  ?>

As you can see, this function needs 2 parameters to be called:

  • A URL ($url)
  • Data ($data)



Step 2 - Find the URL in Mailify and paste it


To connect to the API, we will use the URL from the contact list($url). Copy and paste the URL that appears under 'To insert a contact' in the API access window.


To find this URL, follow the steps in our guide here.


https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw?action=INSERT&Email=contact@domaine.com

We only need to use part of the URL so as to get one that looks like this:

https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw

(everything that comes after "?" was deleted)


Then we get:

<?php    $url = "https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw";   ?>

Step 3 - Send the data


We now have to send the data ($data) that we want to be added to that list:

$data is a chart with data that comes as follows:

<?php    $data=array(       'action' => 'INSERT',       'Email' => $email  );   ?>

/!\ In this example, $email has been previously set up with an email address.


The 'action' box is mandatory as it allows you to choose which of the three actions you want to perform with the data.

The 3 possible values are: 'INSERT', 'UPDATE', 'DELETE'.


The HTML form that is shown above only contains the 'Email' box, the $data table thus only has the 'Email' box.


/!\ The contact list only has the 'Email' column by default. If you decide to add columns to your list, you will also have to add them to your list and report them into the $data chart.



Example with more than one column


Example with a list that shows the email, first name, surname columns:

<?php    $data=array(       'action' => 'INSERT',       'Email' => $email,       'Prenom' => $prenom,       'Nom' => $nom  );   ?>

Once the values have been reported in the '$data' column, you just have to send it to the API with the following command.

<?php    post_to_url($url, $data);   ?> 

Your data has now been included in your contact list.
/!\ Mailify updates your contact list every 4 minutes. To force the list update, restart the software.



Summary of the PHP code file


<?php    function post_to_url($url, $data) {    $fields = '';    foreach($data as $key => $value) {       $fields .= $key . '=' . $value . '&';    }    rtrim($fields, '&');     $post = curl_init();    curl_setopt($post, CURLOPT_URL, $url);    curl_setopt($post, CURLOPT_POST, count($data));    curl_setopt($post, CURLOPT_POSTFIELDS, $fields);    curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);     $result = curl_exec($post);     curl_close($post); }  //We now have data to send:   $url = "https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw";   $email = $_POST["email"];  $data=array(       'action' => 'INSERT',       'Email' => $email   );  //Sending data   post_to_url($url, $data);   ?>

To connect to the API, you need to carry out the following steps:


Step 1 - Find the URL for the contact lists.

To find this URL, follow the steps in our guide here.


Step 2 - Copy the URL of the action which you want to take

(INSERT, UPDATE, DELETE)


Example


In our example, the action we will use will be "insert a contact"


https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw?action=INSERT&Email=email@yourdomain.com

This URL is composed of two parts:


1. → https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw which allows you to identify your list.

2. → ?action=INSERT&Email=email@yourdomain.com which represents the data sent in the URL.


What do these characters mean?


The chain of characters "action=INSERT" allows you to choose which action to carry out (In this case, the action is INSERT which means insert contacts to the list).

The character '&' allows you to separate different data sent with the URL.

Email=email@yourdomain.com corresponds to the column "Email" which will be filled in with the value "email@yourdomain.com"


/!\ If your list contains a lot of columns, Mailify will fill in the URL with all the different data.


Here is an example of a URL that contains a field for email, name and surname.


https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw?action=INSERT&Email=contact@domaine.com&NSurname=value&Name=value

Step 3 - Paste the URL


Once the URL has been obtained, you just need to replace the content of the URL variable with the URL containing your data. (The rest of your ASP code allows you to send the request, therefore you don´t need to edit it.)

<% url="https://api-sd.sarbacane.com/lists/325/7CsS69R44UaSy7TazcRLMw?action=INSERT&Email=contact@domain.com&Surname=value&Name=value" Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0") xmlhttp.open "GET", url, false xmlhttp.send data %>

X

Votre avis nous intéresse

Vous avez récemment été en contact avec notre équipe et nous aimerions savoir ce que vous avez pensé de cet échange.

Quelle note générale donneriez-vous à cette expérience?

(Rapidité de traitement, qualité de la réponse apportée, amabilité de votre interlocuteur...)

1 étant la plus faible et 5 la plus forte

Parce que vous accompagner au mieux est notre priorité, nous avons besoin de votre précieux avis pour continuer à nous améliorer.

Pour quelle raison principale avez-vous attribué cette note ?
X

Vous avez donné une note de /5.

Merci d'avoir partagé votre avis.

Nous sommes désolés que les échanges avec notre équipe ne vous aient pas apporté entière satisfation.

Nous vous proposons de prendre à nouveau contact avec nos équipes pour trouver de meilleures solutions à vos besoins au cours d'un rendez-vous téléphonique.

Make an appointment
X

Vous avez donné une note de /5.

Merci beaucoup pour votre retour d'expérience !

Votre avis est précieux et nous aimerions beaucoup que celui-ci puisse être utile pour des personnes à la recherche d'un outil marketing.

Accepteriez-vous de partager votre avis publiquement ?

Si oui, vous pouvez le laisser ici:

Je partage mon avis

Sarbacane Chat

Ecran d'accueil

You are about to use Mailify Chat

We need your consent to activate the module allowing us to chat with you

Free trial
Bulle chat