<?php
// client can de downloaded from https://github.com/Newsman/newsman-api-php
require_once("Newsman/Client.php");
// you can get your API KEY, your newsman_user_id and list_id from My account -> API
$newsman_user_id = "your-username";
$api_key = "your-api-key";
$newsletter_id = "40001"; // The parent newsletter_id for which this variant is created
$html = "<html> the html code here </html>"; //The html content of the variant. If false or empty, it will use the parent content
$text = "the text version"; // The text alternative of the variant. If false or empty, it will use the parent content
// Hash array with variant props.
$props = array(
"encoding" => "utf-8", /* the default encoding of this variant (default is utf-8). optional */
"subject" => "the newsletter subject", /* the variant subject. if missing it will use the parent value. optional */
"from_name" => "new from name here", /* the variant from name. if missing it will use the parent value. optional */
"from_email" => "new from email here" /* the variant from email. if missing it will use the parent value. optional */
);
try {
$client = new Newsman_Client($newsman_user_id, $api_key);
$ret = $client->abtest->createVariant($newsletter_id, $html, $text, $props);
} catch (Exception $e) {
//do something with the error, eg: log $e->getMessage()
}
return $ret;
?>