Skip to content

Instantly share code, notes, and snippets.

@tpatch
Created February 10, 2017 23:02
Show Gist options
  • Save tpatch/dfe01f28c8a17611ed0976ad02631bdd to your computer and use it in GitHub Desktop.
Save tpatch/dfe01f28c8a17611ed0976ad02631bdd to your computer and use it in GitHub Desktop.
require('ET_Client.php');
$myclient = new \ET_Client();
// NOTE: These examples only work in accounts where the SubscriberKey functionality is not enabled
// SubscriberKey will need to be included in the props if that feature is enabled
// Create Subscriber
$subCreate = new \ET_Subscriber();
$subCreate->authStub = $myclient;
$subCreate->props = array("EmailAddress" => $email, "Lists" => array("ID" => $listId));
$subCreate->props['Attributes'] = array(array('Name' => 'First Name', 'Value' => $firstName), array('Name' => 'Last Name', 'Value' => $lastName), array('Name' => 'Full Name', 'Value' => $fullName));
$postResult = $subCreate->post();
if ($postResult->status){
$sendTrigger = new \ET_TriggeredSend();
$sendTrigger->props = array('CustomerKey' => '0000');
$sendTrigger->authStub = $myclient;
$sendTrigger->subscribers = array(array("EmailAddress" => $email, "SubscriberKey" => $email));
$sendResult = $sendTrigger->send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment