Prerequisites
To get the most out of this guide, you’ll need to:
1. Install
Composer
To install the bindings via Composer, use the following command on the command line:
composer require sendx/sendx-php-sdk
Or, add the following to composer.json
:
"require": {
"sendx/sendx-php-sdk": "1.0.0"
}
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php
require_once('/path/to/sendx/vendor/autoload.php');
2. Getting Started
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: apiKeyAuth
$config = sendx\Configuration::getDefaultConfiguration()->setApiKey('X-Team-ApiKey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = sendx\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-Team-ApiKey', 'Bearer');
$apiInstance = new sendx\Api\ContactApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$contact_request = new \sendx\model\ContactRequest(); // \sendx\model\ContactRequest
$contact_request->setEmail("john@doe.com"); // Required: Set email
$contact_request->setFirstName("John"); // Optional: Set first name
$contact_request->setLastName("Doe"); // Optional: Set last name
$contact_request->setCompany("SendX"); // Optional: Set company
$contact_request->setLastTrackedIp("192.168.1.1"); // Optional: Set last tracked IP
$contact_request->setCustomFields(["sendf13kn2k3kjm2d" => "Developer", "ckjsnck234nm2kn42" => "Engineering"]); // Optional: Set custom fields
$contact_request->setLists(["list_id_1", "list_id_2"]); // Optional: Subscribe to lists
try {
$result = $apiInstance->createContact($contact_request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ContactApi->createContact: ', $e->getMessage(), PHP_EOL;
}
3. Try it for yourself