PHP code example of jan-suchanek / smart-emailing-v3
1. Go to this page and download the library: Download jan-suchanek/smart-emailing-v3 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/ */
jan-suchanek / smart-emailing-v3 example snippets
use SmartEmailing\v3\Api;
...
$api = new Api('username', 'api-key');
// Creates a new instance
$api->import()->addContact(new Contact('[email protected]'))->send();
// Creates a new instance
$import = $api->import();
$contact = new Contact('[email protected]');
$contact->setName('Martin')->setNameDay('2017-12-11 11:11:11');
$import->addContact($contact);
// Create new contact that will be inserted in the contact list
$contact2 = $import->newContact('[email protected]');
$contact2->setName('Test');
// Create new contact that will be inserted in the contact list
$import->newContact('[email protected]')->setName('Test');
$import->send();
use SmartEmailing\v3\Exceptions\RequestException;
try {
$api->ping()->send();
} catch (RequestException $exception) {
$exception->response(); // to get the real response, will hold status and message (also data if provided)
$exception->request(); // Can be null if the request was 200/201 but API returned error status text
}
use SmartEmailing\v3\Request\CustomFields\CustomField;
use SmartEmailing\v3\Request\CustomFields\Create\Response;
...
// Create the new customField and send the request now.
$response = $api->customFields()->create(new CustomField('test', CustomField::TEXT));
// Get the customField in data
$customFieldId = $response->data()->id;
$request = $api->customFields()->createRequest(); // You can pass the customField object
// Setup customField
$customField = new CustomField();
$request->setCustomField($customField);
// Setup data
$customField->setType(CustomField::RADIO)->setName('test');
// Send the request
$response = $request->send();