1. Go to this page and download the library: Download comicrelief/smartfocus 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/ */
comicrelief / smartfocus example snippets
// cURL client for communication with API
use Estina\SmartFocus\Api\Http\CurlClient;
// Member REST API class
use Estina\SmartFocus\Api\Rest\Member;
// helper for XML parsing (optional)
use Estina\SmartFocus\Api\Util\RestResponseParser;
// initialize object, injecting the cURL client
$api = new Member(new CurlClient());
// open the connection, XML is returned, containing token or error description
$xmlResponse = $api->openConnection(
'server hostname',
'your login name',
'your password',
'your API key'
);
if ($xmlResponse) {
// extract token from XML
$parser = new RestResponseParser();
$token = $parser->getResult($xmlResponse);
if ($token) {
// call the API method and fetch the response
$insertResponse = $api->insertMemberByEmailAddress(
$token,
'[email protected]'
);
// close the connection
$api->closeConnection($token);
}
}
// cURL client for communication with API
use Estina\SmartFocus\Api\Http\CurlClient;
// Member REST API class
use Estina\SmartFocus\Api\Rest\Member;
// helper for XML parsing (optional)
use Estina\SmartFocus\Api\Util\RestResponseParser;
// initialize object, injecting the cURL client
$api = new Member(new CurlClient());
// open the connection, XML is returned, containing token or error description
$xmlResponse = $api->openConnection(
'server hostname',
'your login name',
'your password',
'your API key'
);
if ($xmlResponse) {
// extract token from XML
$parser = new RestResponseParser();
$token = $parser->getResult($xmlResponse);
if ($token) {
/*
* Let's build request's XML body with data
*
* <memberUID>:
* Multiple sets of criteria can be combined to identify the member, e.g.
* EMAIL:[email protected]|LASTNAME:Smith
*
* <dynContent>:
* envelope containing the list of fields to be updated and their values
*
* <entry>:
* The entry envelope containing the field to update and its value.
*
* <key>:
* The field that will be updated.
*
* <value>:
* The value with which to update the field.
*/
$xml =
'<?xml version="1.0" encoding="utf-8"
// cURL client for communication with API
use Estina\SmartFocus\Api\Http\CurlClient;
// Member REST API class
use Estina\SmartFocus\Api\Rest\Notification;
// initialize object, injecting the cURL client
$api = new Notification(new CurlClient());
$response = $api->send(
'[email protected]', // Recipient
'abcdefg', // Encrypt value provided in the interface
'132456', // ID of the Template
'123456789', // Random value provided for the template
'firstname:John|lastname:Smith', // Dynamic parameters as a string
'YYYY-MM-DD HH:MM:SS', // optional, The time you wish to send
'email', // Now *REQUIRED* - the key you wish to update, normally email
'NOTHING' // optional, The type of synchronization
);
// cURL client for communication with API
use Estina\SmartFocus\Api\Http\CurlClient;
// Member REST API class
use Estina\SmartFocus\Api\Rest\Notification;
// initialize object, injecting the cURL client
$api = new Notification(new CurlClient());
$recipientEmail = '[email protected]';
$encryptId = 'abcdefg';
$randomId = '132456';
$additionalParams = [
'senddate' => 'YYYY-MM-DDTHH:MM:SS', // 'T' between date & time
'uidkey' => 'email',
'synchrotype' => 'NOTHING'
];
// Optional: Dynamic parameters as an array
$dyn = [
'firstname' => 'John',
'lastname' => 'Smith'
];
$content = [
'click <a href="http://somewhere.com">here</a> please',
'good stuff is available <a href="http://goodstuff.com">here</a>'
];
// Tracking enabled for the links passed in the content blocks.
$enableTracking = true;
// Build request object.
$xmlRequestObject = $api->buildTransactionalRequestObject(
$recipientEmail,
$encryptId,
$randomId,
$dyn,
$content,
$enableTracking,
$additionalParams
);
// Make the request.
$response = $api->post($xmlRequestObject);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.