PHP code example of sendx / sendx-php-sdk

1. Go to this page and download the library: Download sendx/sendx-php-sdk 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/ */

    

sendx / sendx-php-sdk example snippets





Configure API key authorization: TeamApiKey
$config = sendx\Configuration::getDefaultConfiguration()->setApiKey('X-Team-ApiKey', 'YOUR_API_KEY');

$contact_request = new \sendx\model\ContactRequest(); // \sendx\model\ContactRequest
$contact_request->setEmail("[email protected]"); // 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;
}


 composer