From 588c65feb7d55da341e2c50f906131d80d931741 Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Mon, 17 Jun 2013 16:11:00 -0400 Subject: [PATCH 01/12] Fixed issue with Refreshing LegacyTokens --- ET_Client.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ET_Client.php b/ET_Client.php index eb38214..8a41acc 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -46,19 +46,19 @@ function __construct($getWSDL = false, $params = null) { parent::__setLocation($this->endpoint); } - function refreshToken() { + function refreshToken($forceRefresh = true) { try { $currentTime = new DateTime(); - if (is_null($this->authToken) || ($currentTime->diff($this->authTokenExpiration)->format('%i') < 5) ){ + if (is_null($this->authToken) || ($currentTime->diff($this->authTokenExpiration)->format('%i') < 5) || $forceRefresh ){ $url = "https://auth.exacttargetapis.com/v1/requestToken?legacy=1"; $jsonRequest = new stdClass(); $jsonRequest->clientId = $this->clientId; - $jsonRequest->clientSecret = $this->clientSecret; - $jsonRequest->accessType = "offline"; + $jsonRequest->clientSecret = $this->clientSecret; + $jsonRequest->accessType = "offline"; + $jsonRequest->scope = "cas:".$this->internalAuthToken; if (!is_null($this->refreshKey)){ $jsonRequest->refreshToken = $this->refreshKey; } - $authResponse = restPost($url, json_encode($jsonRequest)); $authObject = json_decode($authResponse->body); From 129eb4c6231ddd8694a44d8883bd1847a5f74630 Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Tue, 18 Jun 2013 07:53:29 -0400 Subject: [PATCH 02/12] Prevent refresh token from defaulting to true --- ET_Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ET_Client.php b/ET_Client.php index 8a41acc..23de0b1 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -46,7 +46,7 @@ function __construct($getWSDL = false, $params = null) { parent::__setLocation($this->endpoint); } - function refreshToken($forceRefresh = true) { + function refreshToken($forceRefresh = false) { try { $currentTime = new DateTime(); if (is_null($this->authToken) || ($currentTime->diff($this->authTokenExpiration)->format('%i') < 5) || $forceRefresh ){ From 86fc5f140cd46c8685d0f281308232f23eede4da Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Fri, 21 Jun 2013 11:30:54 -0400 Subject: [PATCH 03/12] Supports storing ET_Client in sessions --- ET_Client.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ET_Client.php b/ET_Client.php index 23de0b1..5fecd88 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -47,6 +47,9 @@ function __construct($getWSDL = false, $params = null) { } function refreshToken($forceRefresh = false) { + if ($this->sdl == 0){ + parent::__construct('ExactTargetWSDL.xml', array('trace'=>1, 'exceptions'=>0)); + } try { $currentTime = new DateTime(); if (is_null($this->authToken) || ($currentTime->diff($this->authTokenExpiration)->format('%i') < 5) || $forceRefresh ){ From bf8cb726f46b7f49a448177b1b5eaa86ca3448b5 Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Tue, 30 Jul 2013 08:52:33 -0400 Subject: [PATCH 04/12] Updated to not use cas for refresh --- ET_Client.php | 1 - 1 file changed, 1 deletion(-) diff --git a/ET_Client.php b/ET_Client.php index 5fecd88..f9dd383 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -58,7 +58,6 @@ function refreshToken($forceRefresh = false) { $jsonRequest->clientId = $this->clientId; $jsonRequest->clientSecret = $this->clientSecret; $jsonRequest->accessType = "offline"; - $jsonRequest->scope = "cas:".$this->internalAuthToken; if (!is_null($this->refreshKey)){ $jsonRequest->refreshToken = $this->refreshKey; } From 6bd4a9f85166c45e1a370400c4f5c3e56b5b6f93 Mon Sep 17 00:00:00 2001 From: David Stanley Date: Thu, 8 Aug 2013 14:09:36 -0700 Subject: [PATCH 05/12] Headline said ruby... --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2469e5c..031e176 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -FuelSDK-Ruby +FuelSDK-PHP ============ ExactTarget Fuel SDK for PHP From e5788b475354dee9305354e432e690fa1ad9e077 Mon Sep 17 00:00:00 2001 From: Benjamin Dean Date: Mon, 26 Aug 2013 11:46:58 -0700 Subject: [PATCH 06/12] Update ET_Client.php Fix a typo in the WSDL fetch. --- ET_Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ET_Client.php b/ET_Client.php index f9dd383..a0b690f 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -102,7 +102,7 @@ function CreateWSDL($wsdlLoc) { } if ($getNewWSDL){ - $newWSDL = file_gET_contents($wsdlLoc); + $newWSDL = file_get_contents($wsdlLoc); file_put_contents("ExactTargetWSDL.xml", $newWSDL); } } From cf93736f7f7475e1e63caa352c2070487a2b5316 Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Fri, 13 Sep 2013 15:12:59 -0400 Subject: [PATCH 07/12] Fixed AddSubscriberToList --- ET_Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ET_Client.php b/ET_Client.php index a0b690f..00831d8 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -160,7 +160,7 @@ function AddSubscriberToList($emailAddress, $listIDs, $subscriberKey = null){ $lists = array(); foreach ($listIDs as $key => $value){ - $list[] = array("ID" => $value); + $lists[] = array("ID" => $value); } $newSub->props = array("EmailAddress" => $emailAddress, "Lists" => $lists); From 324e0fdff2532ce86da3028db952e66436748ddc Mon Sep 17 00:00:00 2001 From: Benjamin Dean Date: Mon, 7 Oct 2013 17:27:22 -0700 Subject: [PATCH 08/12] Issue #13 possible solution to providing the client mid into the send call for contextualization --- ET_Client.php | 7 +++++-- objsamples/sample-triggeredsend.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ET_Client.php b/ET_Client.php index 44b5867..396802e 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -1612,15 +1612,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/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(); From 9eeb230dac7608f0dc213ea65b039e033f764dc4 Mon Sep 17 00:00:00 2001 From: Christopher McCulloh Date: Wed, 23 Oct 2013 17:04:30 -0400 Subject: [PATCH 09/12] Fixed whitespace --- config.php.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.php.template b/config.php.template index 495af94..ce886d4 100644 --- a/config.php.template +++ b/config.php.template @@ -1,9 +1,9 @@ 'none', + 'appsignature' => 'none', 'clientid' => 'CCCCCCCCCCCCCCCCCCCCCCC', 'clientsecret' => 'CCCCCCCCCCCCCCCCCCCCCCC', 'defaultwsdl' => 'https://webservice.exacttarget.com/etframework.wsdl' ); -?> \ No newline at end of file +?> From 65ef525ec343a1579f029c0643f6e37120a21fa2 Mon Sep 17 00:00:00 2001 From: "Herman J. Radtke III" Date: Sun, 24 Nov 2013 00:00:41 -0800 Subject: [PATCH 10/12] Write WSDL to proper tmp directory The local copy of the WSDL file should be written to the systems temporary directory instead of where ever ET_Client.php happens to exist. --- ET_Client.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/ET_Client.php b/ET_Client.php index 8e407a0..efff8a7 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -58,13 +58,13 @@ function __construct($getWSDL = false, $debug = false, $params = null) { } catch (Exception $e) { throw new Exception('Unable to determine stack using /platform/v1/endpoints/: '.$e->getMessage()); } - parent::__construct('ExactTargetWSDL.xml', array('trace'=>1, 'exceptions'=>0)); + parent::__construct($this->LocalWsdlPath(), array('trace'=>1, 'exceptions'=>0)); parent::__setLocation($this->endpoint); } function refreshToken($forceRefresh = false) { if (property_exists($this, "sdl") && $this->sdl == 0){ - parent::__construct('ExactTargetWSDL.xml', array('trace'=>1, 'exceptions'=>0)); + parent::__construct($this->LocalWsdlPath(), array('trace'=>1, 'exceptions'=>0)); } try { $currentTime = new DateTime(); @@ -119,8 +119,8 @@ function CreateWSDL($wsdlLoc) { $remoteTS = $this->GetLastModifiedDate($wsdlLoc); - if (file_exists("ExactTargetWSDL.xml")){ - $localTS = filemtime("ExactTargetWSDL.xml"); + if (file_exists($this->LocalWsdlPath())){ + $localTS = filemtime($this->LocalWsdlPath()); if ($remoteTS <= $localTS) { $getNewWSDL = false; @@ -129,7 +129,7 @@ function CreateWSDL($wsdlLoc) { if ($getNewWSDL){ $newWSDL = file_get_contents($wsdlLoc); - file_put_contents("ExactTargetWSDL.xml", $newWSDL); + file_put_contents($this->LocalWsdlPath(), $newWSDL); } } catch (Exception $e) { @@ -137,6 +137,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($tmp, -1)) { + $tmp .= '/'; + } + } + + return "{$tmpPath}{$wsdlName}"; + + } + function GetLastModifiedDate($remotepath) { $curl = curl_init($remotepath); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); From 7b76b25e889188558699b006c3f24184dc959ad9 Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Wed, 12 Feb 2014 13:35:30 -0500 Subject: [PATCH 11/12] Fixed issue with path for Windows --- .gitignore | 1 + ET_Client.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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 efff8a7..798d7e1 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -149,8 +149,8 @@ function LocalWsdlPath() // 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($tmp, -1)) { - $tmp .= '/'; + if ('/' !== substr($tmpPath, -1)) { + $tmpPath .= '/'; } } From 9462d688fd6c5ee559aaa4c79d515124a287cd5b Mon Sep 17 00:00:00 2001 From: "Mark A. Stratman" Date: Fri, 21 Feb 2014 13:14:01 -0600 Subject: [PATCH 12/12] Fixed ErrorException for incompatible __doRequest ErrorException Object ( [message:protected] => Declaration of ET_Client::__doRequest() should be compatible with SoapClient::__doRequest($request, $location, $action, $version, $one_way = NULL) [string:Exception:private] => [code:protected] => 0 [file:protected] => /home/mark/code/parkwhiz.com/app/ET_Client.php [line:protected] => 465 [trace:Exception:private] => Array ( [0] => Array ( [function] => fatal_error_checker [class] => JMVC [type] => :: [args] => Array ( ) ) ) [previous:Exception:private] => [severity:protected] => 2048 ) --- ET_Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ET_Client.php b/ET_Client.php index 798d7e1..c885b46 100644 --- a/ET_Client.php +++ b/ET_Client.php @@ -173,7 +173,7 @@ function GetLastModifiedDate($remotepath) { return curl_getinfo($curl, CURLINFO_FILETIME); } - function __doRequest($request, $location, $saction, $version) { + function __doRequest($request, $location, $saction, $version, $one_way=null) { $doc = new DOMDocument(); $doc->loadXML($request);