PHP code example of mediapart / selligent
1. Go to this page and download the library: Download mediapart/selligent 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/ */
mediapart / selligent example snippets
# example.php
gent\Connection;
use Mediapart\Selligent\Transport;
use Mediapart\Selligent\Properties;
/* connect you to your Selligent API server */
$connection = new Connection();
$client = $connection->open([
'login' => '*****',
'password' => '*****',
'wsdl' => 'http://emsecure/individual?wsdl',
]);
/*
Example : Trigger the TESTGATE campaign to an user.
We will register the user first an then, we will trigger
the campaign with a custom message :
*/
try {
$transport = new Transport($client);
$user = new Properties();
$user['NAME'] = 'Foo Bar';
$user['MAIL'] = '[email protected]';
$userId = $transport
->setList($config['list'])
->subscribe($user)
;
$inputData = new Properties();
$inputData['MESSAGE'] = 'Lorem ipsum dolor sit amet conceptuem.';
$result = $transport
->setCampaign($config['campaign'])
->triggerCampaign($userId, $inputData)
;
} catch (\Exception $e) {
echo 'something bad happens.';
}