PHP code example of mizmoz / php-api

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

    

mizmoz / php-api example snippets


use Mizmoz\API\Client;

// Use the apiId and apiKey provided in the admin interface 
// Mizmoz.com > Admin > Access > API Access
$client = new Client($apiId, $apiKey);

use Mizmoz\API\EmailList\Email\Create;

// Set the emailListId (ionally you can set the title
$create->setTitle('Miss');

// Last name
$create->setLastName('Chadwick');

// Email source, this gives you a way of identifying where the subscriber came from.
// For example, website, facebook, xmas-campaign
$create->setSource('website');

// Set the subscriber created date, by default the current time and date will be used
// this can be useful if you're doing batch additions after a few days. Always be careful adding
// old data though, we want to keep our lists in good health!
$create->setCreated(new \DateTime('2016-01-26 09:00:00'));

// You can set additional info with the subscriber by using the subscriber meta store
// Before you can set extra data please add the extra columns to the email list
// Mizmoz.com > Email Lists > Settings > Add Fields in the Merge fields section
$create->setMeta('customerId', '12345');

// Execute the create command 
$response = $client->execute($create);

var_dump($response);

use Mizmoz\API\EmailCampaign\Send;

// Set the email campaign id, email list id and email - this can be either emailId, and 
// email address or array of details
// ['emailAddress' => '[email protected]', 'emailFirstname' => 'Me']
$send = new Send($emailCampaignId, $emailListId, $emailId, [
   // This will be usable in the template with: {{live.message}}
   'message' => 'Just something to show variables being passed in to a template'
]);

$response = $client->execute($send);

var_dump($response);

# composer 

"  "mizmoz/php-api": "dev-master"
}