PHP code example of omnisend / php-sdk

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

    

omnisend / php-sdk example snippets






$options = array(
    'timeout' => 30,
    'verifySSL' => false
);
$omnisend = new Omnisend('API-KEY', $options);

$cart = $omnisend->delete('carts/cart-123');
if ($cart) {
    //request was successful
} else {
    //there was an error
}

 var_dump($omnisend->lastError());
 

array {
  ["error"]=> "2 error(s) found. Check 'fields' array for details."
  ["statusCode"]=> 400
  ["fields"]=>
  array {
    [0]=>
    array {
      [0]=> "cartSum: field 

$omnisend = new Omnisend('your-api-key');

$contacts = $omnisend->post(
  'contacts',
   array(
       "email" => "[email protected]", 
       "firstName" => "Vanessa", 
       "lastName" => "Kensington", 
       "status" => "subscribed", 
       "statusDate" => "2018-12-11T10:29:43+00:00"
    )
);

if ($contacts) {
    //request was successful

    //print response
    print_r($contacts); 
    //get contactID from response
    $contactID = $contacts['contactID'];
} else {
    //there was an error
    print_r($omnisend->lastError());
}

composer  install