Skip to content

alanevans/sailthru-php5-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sailthru-php5-client

A simple client library to remotely access the Sailthru REST API as per http://docs.sailthru.com/api

It can make requests to following API calls:

Examples

Constructor

$api_key = "api_key";
$api_secret = 'secret';
$sailthruClient = new Sailthru_Client($api_key, $api_secret);
//send
$response = $sailthruClient->send('temlate-name', '[email protected]', array('name' => 'unix'), array('test' => 1));

//multi send
$response = $sailthruClient->multisend('default', '[email protected],[email protected]', array('name' => 'unix'), array(), array('test' => 1));

//get send
$response = $sailthruClient->getSend("TUMVqWdj2exnAAV-");

//cancel send
$response = $sailthruClient->cancelSend("TUMYT2dj2fl1AABD");
//get email information of a user
$response = $sailthruClient->getEmail("[email protected]");

//update user info
$email = '[email protected]';
$vars = array('name' => 'Prajwal Tuladhar');
$lists = array('list-a' => 1, 'list-b' => 1);
$templates = array('template-1' => 1, 'template-2' => 2);
$verified = 1;
$response = $sailthruClient->setEmail($email, $vars, $lists, $templates, $verified);
//schedule blast
$blast_name = 'test_blast1';
$list = 'default';
$schedule_time = '+1 days';
$from_name = 'Prajwal Tuladhar';
$from_email = '[email protected]';
$subject = "Hey what's up!";
$content_html = "<b>Lorem ipsum dolor si</b>";
$content_text = strip_tags($content_html);

$response = $sailthruClient->scheduleBlast($blast_name, $list, $schedule_time, $from_name, $from_email, $subject, $content_html, $content_text);

//schedule blast from template
$template = 'default';
$list = 'default';
$schedule_time = 'now';
$options  = array();
#$response = $sailthruClient->scheduleBlastFromTemplate($template, $list, $schedule_time, $options);

//schedule blast from previous blast
//Note: if blast_id is invalid, request won't work
$_blast_id = '110065';
$_schedule_time = 'now';
$_options = array(
    'vars' => array(
        'my_var' => '3y6366546363',
        'my_var2' => array(7,8,9),
        'my_var3' => array('president' => 'obama', 'nested' => array('vp' => 'palin'))),
);
$response = $sailthruClient->scheduleBlastFromBlast($_blast_id, $_schedule_time, $_options);



//update blast
$blast_id = 46513;
$blast_name = 'test_blast88';
$response = $sailthruClient->updateBlast($blast_id, $blast_name, $list, $schedule_time, $from_name, $from_email, $subject, $content_html, $content_text);

//cancel scheduled blast
$response = $sailthruClient->cancelBlast($blast_id);

//delete blast
$response = $sailthruClient->deleteBlast($blast_id);
//get metadata for all lists
$lists_metadata = $sailthruClient->getLists();

//download a list
$list = 'default';
$response = $sailthruClient->getList($list, "txt");

//saves /updates a list
$emails = '[email protected], [email protected]';
$response = $sailthruClient->saveList($list, $emails);

//delete a list
$response = $sailthruClient->deleteList($list);
//import contacts
$response = $sailthruClient->importContacts('[email protected]', "your-super-secret-password");
//push content
$title = 'hello world';
$url = 'http://example.com/product-url';
$response = $sailthruClient->pushContent($title, $url);

//another push content example
$title = 'hello world';
$url = 'http://example.com/product-url';
$date = null;
$tags = array("blue", "red", "green");
$vars = array('vars' => array('price' => 17299));
$response = $sailthruClient->pushContent($title, $url, $date, $tags, $vars);
//Retrieve a user's alert settings.
$email = '[email protected]';
$response = $sailthruClient->getAlert($email);

//saves an alert for a user
$email = '[email protected]';
$alert_type = 'realtime';
$options = array(
    'match' => array(
        'type' => array(
            'shoes', 'shirts'
        )
    ),
    'min' => array(
        'price' => 3000
    ),
    'tags' => array('blue', 'red')
);
$when = null;
$template = 'my-template';
$response = $sailthruClient->saveAlert($email, $alert_type, $template, $when, $options);


//deletes an alert
$email = '[email protected]';
$alert_id = '4d463bad6763d90e0e000581';
$response = $sailthruClient->deleteAlert($email, $alert_id);
//post purchase
$email = '[email protected]';
$items = array(
	array('id' => 11, 'price' => 26262, 'qty' => '11', 'url' => 'http://example.com/234/high-impact-water-bottle', 'title' => 'High-Impact Water Bottle'),
	array('id' => 171, 'price' => 262, 'qty' => '18', 'url' => 'http://xyz.com/abc', 'title' => 'some title2')
);
$response = $sailthruClient->purchase($email, $items);
//get list stats
$response = $sailthruClient->stats_list();

//get blast stats
$blast_id = 6752;
$response = $sailthruClient->stats_blast($blast_id);
//gets horizon data for a user
$email = ''[email protected];
$hid_only = false;
$response = $sailthruClient->getHorizon($email, $hid_only);

//sets horizon user data
$email = '[email protected]';
$tags = array('blue', 'red', 'green');
$response = $sailthruClient->getHorizon($email, $tags);

//set horizon cookie
$email = '[email protected]';
$sailthruClient->setHorizonCookie($email);
//recieve verify post
$sailthruClient->receiveVerifyPost();

//recieve optout post
$sailthruClient->receiveOptoutPost();

About

Sailthru PHP5 Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published