PHP code example of invia-de / emarsys
1. Go to this page and download the library: Download invia-de/emarsys library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
invia-de / emarsys example snippets
$username = 'your_username';
$secret = 'your_secret';
$client = new \Emarsys\Client($username, $secret);
// Retrieve a contact from his email address
$response = $client->getContact(array(3 => '[email protected] '));
// Create a contact with just his email information
$response = $client->createContact(array(3 => '[email protected] '));
// Create a more complex contact
$response = $client->createContact(array(
'email' => '[email protected] ',
'gender' => $client->getChoiceId('gender', 'male'),
'salutation' => $client->getChoiceId('salutation', 'mr'),
'firstName' => 'John',
'lastName' => 'Doe',
'birthDate' => '2014-03-27',
'address' => 'Forgotten street 85B',
'zip' => '1000',
'city' => 'Brussels',
'country' => 17,
'language' => 3,
));
$client->addFieldsMapping(array('petName' => 7849, 'twitter' => 7850));`
$response = $client->createContact(array(1 => 'John', 2 => 'Doe', 3 => '[email protected] '));
$response = $client->createContact(array('firstName' => 'John', 'lastName' => 'Doe', 'email' => '[email protected] '));
$fieldId = $client->getFieldId('firstName');
// will return 1;
$fieldName= $client->getFieldName(1);
// will return 'firstName';
$client = new Client($username, $secret, null, array('firstName' => 1, 'lastName' => 2));
$client->addChoicesMapping(array('gender' => array('male' => 1, 'female' => 2)));
$response = $client->getFieldChoices(5);
$response = $client->getFieldChoices('gender');
$choiceId = $client->getChoiceId('gender', 'male');
// will return 1;
$choiceName= $client->getChoiceName('gender', 1);
// will return 'male';
$client = new Client($username, $secret, null, null, [], array('gender' => array('male' => 1, 'female' => 2)));
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
# Add Emarsys as a dependency
php composer.phar