diff --git a/lib/CAC/Component/ESP/Api/Engine/EngineApi.php b/lib/CAC/Component/ESP/Api/Engine/EngineApi.php index babf324..c7b225d 100644 --- a/lib/CAC/Component/ESP/Api/Engine/EngineApi.php +++ b/lib/CAC/Component/ESP/Api/Engine/EngineApi.php @@ -42,13 +42,15 @@ public function __construct(array $config) { $this->config = array_replace_recursive( array( + "wsdl" => null, "secure" => false, "domain" => "", "path" => "/soap/server.live.php", "customer" => "", "user" => "", "password" => "", - "trace" => false + "trace" => false, + "mailinglist" => null, ), $config ); @@ -149,6 +151,10 @@ public function sendMailing($mailingId, array $users, $date = null, $mailinglist $date = date("Y-m-d H:i:s"); } + if (null === $mailinglistId) { + $mailinglistId = $this->config['mailinglist']; + } + // Check if users are set if (empty($users)) { throw new EngineApiException("No users to send mailing"); @@ -156,10 +162,10 @@ public function sendMailing($mailingId, array $users, $date = null, $mailinglist $result = $this->performRequest( 'Subscriber_sendMailingToSubscribers', - $mailingId, + intval($mailingId), $date, $users, - $mailinglistId + intval($mailinglistId) ); if (!is_numeric($result)) { @@ -172,6 +178,18 @@ public function sendMailing($mailingId, array $users, $date = null, $mailinglist return $result; } + /** + * Select a Mailinglist + * + * @param integer $mailinglistId + * + * @return string + */ + public function selectMailinglist($mailinglistId) + { + return $this->performRequest('Mailinglist_select', intval($mailinglistId)); + } + /** * Subscribe a User to a Mailinglist * @@ -330,10 +348,10 @@ protected function getConnection() if ($this->connection === null) { // create a connection $connection = new \SoapClient( - null, + $this->config['wsdl'], array( - "location" => "http" . (($this->config['secure']) ? 's' : '') . "://" . $this->config["domain"] . $this->config["path"], - "uri" => "http" . (($this->config['secure']) ? 's' : '') . "://" . $this->config["domain"] . $this->config["path"], + //"location" => "http" . (($this->config['secure']) ? 's' : '') . "://" . $this->config["domain"] . $this->config["path"], + //"uri" => "http" . (($this->config['secure']) ? 's' : '') . "://" . $this->config["domain"] . $this->config["path"], "login" => $this->config["customer"] . "__" . $this->config["user"], "password" => $this->config["password"], "trace" => $this->config["trace"] @@ -341,6 +359,11 @@ protected function getConnection() ); $this->connection = $connection; + + if ($this->config['mailinglist']) { + // Select the default mailinglist + $this->selectMailinglist($this->config['mailinglist']); + } } return $this->connection;