From aafdc6bdeb382a7b6de74f9d17186902f6b870dd Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 26 Apr 2017 18:13:43 +1200 Subject: [PATCH 1/2] Add new methods: - getAggregateTrackingForMailing - getSentMailingsForOrg - getMailingTemplate And dates to getMailingTemplates --- src/Silverpop/EngagePod.php | 77 ++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/src/Silverpop/EngagePod.php b/src/Silverpop/EngagePod.php index 9785698..d32f991 100644 --- a/src/Silverpop/EngagePod.php +++ b/src/Silverpop/EngagePod.php @@ -93,11 +93,13 @@ public function getLists($listType = 2, $isPrivate = true, $folder = null) { * Get mailing templates * */ - public function getMailingTemplates($isPrivate = true) { + public function getMailingTemplates($isPrivate = true, $startDate, $endDate) { $data["Envelope"] = array( "Body" => array( "GetMailingTemplates" => array( "VISIBILITY" => ($isPrivate ? '0' : '1'), + "LAST_MODIFIED_START_DATE" => $startDate, + "LAST_MODIFIED_END_DATE" => $endDate, ), ), ); @@ -114,6 +116,79 @@ public function getMailingTemplates($isPrivate = true) { } } + /** + * Get a specific mailing template. + * + * @param $mailingID + * @return mixed + * @throws \Exception + */ + public function getMailingTemplate($mailingID) { + $data["Envelope"] = array( + "Body" => array( + "PreviewMailing" => array( + "MailingId" => $mailingID + ), + ), + ); + $response = $this->_request($data); + return $response["Envelope"]["Body"]["RESULT"]; + } + + /** + * Get all the sent mails for an organization. + * + * @param string $startDate + * Date string acceptable to strtotime. + * @param string $endDate + * Date string acceptable to strtotime. + * + * @return array + * @throws \Exception + */ + public function getSentMailingsForOrg($startDate = 'a week ago', $endDate = 'now') { + $data["Envelope"] = array( + "Body" => array( + 'GetSentMailingsForOrg' => array( + 'SENT' => '1', + "DATE_START" => date('m/d/Y H:i:s', strtotime($startDate)), + "DATE_END" => date('m/d/Y H:i:s', strtotime($endDate)), + "SHARED" => '1', + "EXCLUDE_ZERO_SENT" => '1', + "EXCLUDE_TEST_MAILINGS" => '1', + ), + ) + ); + + $response = $this->_request($data); + return $response["Envelope"]["Body"]["RESULT"]['Mailing']; + } + + + /** + * Get all the sent mails for an organization. + * + * @param int $mailingID + * Integer for mailing id. + * @param int $reportID + * Report id. + * + * @return array + * @throws \Exception + */ + public function getAggregateTrackingForMailing($mailingID, $reportID) { + $data["Envelope"] = array( + "Body" => array( + 'GetAggregateTrackingForMailing' => array( + 'MAILING_ID' => $mailingID, + "REPORT_ID" => $reportID, + ), + ) + ); + + $response = $this->_request($data); + return $response["Envelope"]["Body"]["RESULT"]['Mailing']; + } /** * Calculate a query * From 7400e1633f6ba1018d7da0ebb0865fcb555cef59 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 May 2017 16:47:16 +1200 Subject: [PATCH 2/2] Fix to https & add function --- src/Silverpop/EngagePod.php | 54 ++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/Silverpop/EngagePod.php b/src/Silverpop/EngagePod.php index d32f991..9d7316e 100644 --- a/src/Silverpop/EngagePod.php +++ b/src/Silverpop/EngagePod.php @@ -30,7 +30,7 @@ public function __construct($config) { // It would be a good thing to cache the jsessionid somewhere and reuse it across multiple requests // otherwise we are authenticating to the server once for every request - $this->_baseUrl = 'http://api' . $config['engage_server'] . '.silverpop.com/XMLAPI'; + $this->_baseUrl = 'https://api' . $config['engage_server'] . '.silverpop.com/XMLAPI'; $this->_login($config['username'], $config['password']); } @@ -189,6 +189,7 @@ public function getAggregateTrackingForMailing($mailingID, $reportID) { $response = $this->_request($data); return $response["Envelope"]["Body"]["RESULT"]['Mailing']; } + /** * Calculate a query * @@ -834,6 +835,57 @@ public function importList($fileName, $mapFileName) { } + /** + * Import a list/database + * + * Requires a file to import and a mapping file to be in the 'upload' directory of the Engage FTP server + * + * $listID int + * ID of the list + * $date_start string + * $date_end string + * $parameters array + * Array of optional parameters, possibly including + * - export_type ALL|UNDELIVERABLE|OPT_IN|OPT_OUT (default ALL) + * - export_format CSV|TAB|PIPE (default csv) + * - file_encoding utf-8|iso-8859-1 (default = org default) + * - add_to_stored_files bool (default false) + * .... + * + */ + public function exportList($listID) { + + $data["Envelope"] = array( + "Body" => array( + "ExportList" => array( + "LIST_ID" => $listID, + "EXPORT_TYPE" => 'ALL', + "EXPORT_FORMAT" => 'CSV', + "DATE_START" => '04/25/2017 12:12:11', + "USE_CREATED_DATE" => 1, + "EXPORT_COLUMNS" => array("Email","Opt In Date","Opted Out","Opt In Details","Email Type","Opted Out Date","Opt Out Details","20151203_Amount","20151203_AmountDouble","AOL_2017_Program","ContactID","ContributionID","IsoLang","LastClickDate","LastOpenDate","LastSentDate","Segment","Segment_AOL","Segment_Newsletter","Segment_Newsletter2","SendHour","bannerInfo_country","bannerInfo_language","bannerInfo_segment","bannerInfo_source","bannerInfo_submitDate","country","donation_count","firstname","highest_donation_date","highest_native_amount","highest_native_currency","highest_usd_amount","is_2006_donor","is_2007_donor","is_2008_donor","is_2009_donor","is_2010_donor","is_2011_donor","is_2012_donor","is_2013_donor","is_2014_donor","lastname","latest_currency","latest_donation_date","latest_native_amount","latest_usd_amount","lifetime_usd_total","pm_method","postal_code","rml_country","rml_device","rml_language","rml_phone","rml_segment","rml_source","rml_submitDate","state","timezone", + + ), + ), + ), + ); + + + $response = $this->_request($data); + $result = $response["Envelope"]["Body"]["RESULT"]; + + if ($this->_isSuccess($result)) { + if (isset($result['FILE_PATH'])) + return $result['FILE_PATH']; + else { + throw new \Exception('Export list query created but no job ID was returned from the server.'); + } + } else { + throw new \Exception("importList Error: ".$this->_getErrorFromResponse($response)); + } + + } + /** * Get a data job status *