diff --git a/.gitignore b/.gitignore index 8dadf66..aff6210 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ config.php /objsamples/ExactTargetWSDL.xml /objsamples/AllTest.bat .DS_Store +objsamples/sample-testing.php diff --git a/ET_Client.php b/ET_Client.php index 13ea651..8157506 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -145,6 +145,27 @@ function CreateWSDL($wsdlLoc) { } } + function LocalWsdlPath() + { + $wsdlName = 'ExactTargetWSDL.xml'; + $tmpPath = ''; + + // if open_basedir is set then we cannot trust sys_get_temp_dir() + // see http://php.net/manual/en/function.sys-get-temp-dir.php#97044 + if ('' === ini_get('open_basedir')) { + $tmpPath = sys_get_temp_dir(); + + // sys_get_temp_dir() does not return a trailing slash on all OS's + // see http://php.net/manual/en/function.sys-get-temp-dir.php#80690 + if ('/' !== substr($tmpPath, -1)) { + $tmpPath .= '/'; + } + } + + return "{$tmpPath}{$wsdlName}"; + + } + function GetLastModifiedDate($remotepath) { $curl = curl_init($remotepath); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); @@ -1620,15 +1641,18 @@ function __construct() { } class ET_TriggeredSend extends ET_CUDSupport { - public $subscribers, $folderId; + public $subscribers, $folderId, $client; function __construct() { $this->obj = "TriggeredSendDefinition"; $this->folderProperty = "CategoryID"; $this->folderMediaType = "triggered_send"; } - public function Send() { + public function Send( $clientMID = null ) { $tscall = array("TriggeredSendDefinition" => $this->props , "Subscribers" => $this->subscribers); + if( !empty( $clientMID ) && "string" == gettype( $clientMID ) ) { + $tscall["Client"] = array( "ID" => $clientMID ); + } $response = new ET_Post($this->authStub, "TriggeredSend", $tscall); return $response; } diff --git a/config.php.template b/config.php.template index 0389781..7b5d78b 100644 --- a/config.php.template +++ b/config.php.template @@ -1,8 +1,9 @@ 'none', + 'appsignature' => 'none', 'clientid' => 'CCCCCCCCCCCCCCCCCCCCCCC', 'clientsecret' => 'CCCCCCCCCCCCCCCCCCCCCCC', 'defaultwsdl' => 'https://webservice.exacttarget.com/etframework.wsdl', 'xmlloc' => '/some/path/to/cache/ExactTargetWSDL.xml', ); +?> diff --git a/objsamples/sample-triggeredsend.php b/objsamples/sample-triggeredsend.php index 779d76a..a9769d6 100644 --- a/objsamples/sample-triggeredsend.php +++ b/objsamples/sample-triggeredsend.php @@ -95,6 +95,22 @@ print_r($sendResult->results); print "\n---------------\n"; + $clientMID = '0000001'; + + // Send an email with TriggeredSend with Client context + print_r("Send an email using a triggered send with Client context\n"); + $sendTrigger = new ET_TriggeredSend(); + $sendTrigger->props = array('CustomerKey' => 'TEXTEXT'); + $sendTrigger->authStub = $myclient; + $sendTrigger->subscribers = array(array("EmailAddress" => "testing@bh.exacttarget.com", "SubscriberKey" => "testing@bh.exacttarget.com")); + $sendResult = $sendTrigger->send( $clientMID ); + print_r('Send Status: '.($sendResult->status ? 'true' : 'false')."\n"); + print 'Code: '.$sendResult->code."\n"; + print 'Message: '.$sendResult->message."\n"; + print 'Results: '."\n"; + print_r($sendResult->results); + print "\n---------------\n"; + // Generate a unique identifier for the TriggeredSend customer key since they cannot be re-used even after deleted $TSNameForCreateThenDelete = uniqid();