├── .gitignore ├── MailWizzApi ├── Autoloader.php ├── Base.php ├── Cache │ ├── Abstract.php │ ├── Apc.php │ ├── Database.php │ ├── Dummy.php │ ├── File.php │ ├── Xcache.php │ └── data │ │ ├── cache │ │ └── .gitignore │ │ ├── db │ │ └── .gitignore │ │ └── index.html ├── Config.php ├── Endpoint │ ├── CampaignBounces.php │ ├── CampaignUnsubscribes.php │ ├── Campaigns.php │ ├── CampaignsTracking.php │ ├── Countries.php │ ├── Customers.php │ ├── ListFields.php │ ├── ListSegments.php │ ├── ListSubscribers.php │ ├── Lists.php │ ├── Templates.php │ └── TransactionalEmails.php ├── Http │ ├── Client.php │ ├── Request.php │ └── Response.php ├── Params.php ├── ParamsIterator.php ├── Test │ ├── Base.php │ └── Endpoint │ │ └── ListsTest.php ├── autoload.php └── license │ ├── mailwizz-php-sdk.txt │ └── yiiframework.txt ├── README.md ├── composer.json ├── examples ├── ajax_subscribe.php ├── campaign_bounces.php ├── campaigns.php ├── campaigns_tracking.php ├── countries.php ├── customers.php ├── list_fields.php ├── list_segments.php ├── list_subscribers.php ├── lists.php ├── lists_create.php ├── lists_update.php ├── setup.php ├── template-example.html ├── template-example.zip ├── templates.php └── transactional_emails.php ├── php_cs.dist ├── phpstan.neon └── phpunit.xml.dist /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .php_cs.cache 4 | vendor 5 | composer.lock -------------------------------------------------------------------------------- /MailWizzApi/Autoloader.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | 11 | /** 12 | * The MailWizzApi Autoloader class. 13 | * 14 | * From within a Yii Application, you would load this as: 15 | * 16 | *
17 | * require_once(Yii::getPathOfAlias('application.vendors.MailWizzApi.Autoloader').'.php'); 18 | * Yii::registerAutoloader(array('MailWizzApi_Autoloader', 'autoloader'), true); 19 | *20 | * 21 | * Alternatively you can: 22 | *
23 | * require_once('Path/To/MailWizzApi/Autoloader.php'); 24 | * MailWizzApi_Autoloader::register(); 25 | *26 | * 27 | * @author Serban George Cristian
102 | * $components = array( 103 | * 'cache'=>array( 104 | * 'class' => 'MailWizzApi_Cache_Sqlite', 105 | * 'connectionString' => 'sqlite:/absolute/path/to/your/sqlite.db', 106 | * ), 107 | * ); 108 | * $context->setComponents($components); 109 | *110 | * 111 | * Please note, if a named component exists, and you assign one with the same name, 112 | * it will get overriden by the second one. 113 | * 114 | * @param array $components 115 | * 116 | * @return MailWizzApi_Base 117 | * @throws Exception 118 | */ 119 | public function setComponents(array $components) 120 | { 121 | foreach ($components as $componentName => $config) { 122 | $this->setComponent($componentName, $config); 123 | } 124 | return $this; 125 | } 126 | 127 | /** 128 | * Set a single component used throughout the application lifecyle. 129 | * 130 | * The component config array needs to have a `class` key containing a class name that can be autoloaded. 131 | * For example, adding a cache component would be done like : 132 | * 133 | *
134 | * $context->setComponent('cache', array( 135 | * 'class' => 'MailWizzApi_Cache_Sqlite', 136 | * 'connectionString' => 'sqlite:/absolute/path/to/your/sqlite.db', 137 | * )); 138 | *139 | * 140 | * Please note, if a named component exists, and you assign one with the same name, 141 | * it will get overriden by the second one. 142 | * 143 | * @param string $componentName the name of the component accessed later via $context->componentName 144 | * @param array $config the component configuration array 145 | * 146 | * @return MailWizzApi_Base 147 | * @throws ReflectionException 148 | * @throws Exception 149 | */ 150 | public function setComponent($componentName, array $config) 151 | { 152 | if (empty($config['class'])) { 153 | throw new Exception('Please set the class property for "'.htmlspecialchars($componentName, ENT_QUOTES, 'utf-8').'" component.'); 154 | } 155 | $component = new $config['class']; 156 | if ($component instanceof MailWizzApi_Base) { 157 | $component->populateFromArray($config); 158 | } else { 159 | unset($config['class']); 160 | foreach ($config as $property => $value) { 161 | if (property_exists($component, $property)) { 162 | $reflection = new ReflectionProperty($component, $property); 163 | if ($reflection->isPublic()) { 164 | $component->$property = $value; 165 | } 166 | } 167 | } 168 | } 169 | $this->addToRegistry($componentName, $component); 170 | return $this; 171 | } 172 | 173 | /** 174 | * Register one or more callbacks/event handlers for the given event(s) 175 | * 176 | * A valid registration would be: 177 | * 178 | *
179 | * $eventHandlers = array( 180 | * 'eventName1' => array($object, 'method'), 181 | * 'eventName2' => array( 182 | * array($object, 'method'), 183 | * array($object, 'otherMethod'), 184 | * ) 185 | * ); 186 | *187 | * 188 | * @param array $eventHandlers 189 | * 190 | * @return MailWizzApi_Base 191 | * @throws Exception 192 | */ 193 | public function setEventHandlers(array $eventHandlers) 194 | { 195 | foreach ($eventHandlers as $eventName => $callback) { 196 | if (empty($callback) || !is_array($callback)) { 197 | continue; 198 | } 199 | if (!is_array($callback[0]) && is_callable($callback)) { 200 | $this->getEventHandlers($eventName)->add(null, $callback); 201 | continue; 202 | } 203 | if (is_array($callback[0])) { 204 | foreach ($callback as $cb) { 205 | if (is_callable($cb)) { 206 | $this->getEventHandlers($eventName)->add(null, $cb); 207 | } 208 | } 209 | } 210 | } 211 | return $this; 212 | } 213 | 214 | /** 215 | * Return a list of callbacks/event handlers for the given event 216 | * 217 | * @param string $eventName 218 | * 219 | * @return MailWizzApi_Params 220 | * @throws Exception 221 | */ 222 | public function getEventHandlers($eventName) 223 | { 224 | if (!(self::$_eventHandlers instanceof MailWizzApi_Params)) { 225 | self::$_eventHandlers = new MailWizzApi_Params(self::$_eventHandlers); 226 | } 227 | 228 | if (!self::$_eventHandlers->contains($eventName) || !(self::$_eventHandlers->itemAt($eventName) instanceof MailWizzApi_Params)) { 229 | self::$_eventHandlers->add($eventName, new MailWizzApi_Params()); 230 | } 231 | 232 | return self::$_eventHandlers->itemAt($eventName); 233 | } 234 | 235 | /** 236 | * Remove all the event handlers bound to the event name 237 | * 238 | * @param string $eventName 239 | * 240 | * @return MailWizzApi_Base 241 | * @throws Exception 242 | */ 243 | public function removeEventHandlers($eventName) 244 | { 245 | self::$_eventHandlers->remove($eventName); 246 | return $this; 247 | } 248 | 249 | /** 250 | * Called from within a child class, will populate 251 | * all the setters matching the array keys with the array values 252 | * 253 | * @param array $params 254 | * 255 | * @return MailWizzApi_Base 256 | * @throws ReflectionException 257 | */ 258 | protected function populateFromArray(array $params = array()) 259 | { 260 | foreach ($params as $name => $value) { 261 | $found = false; 262 | 263 | if (property_exists($this, $name)) { 264 | $param = (string)$name; 265 | } else { 266 | $asSetterName = str_replace('_', ' ', $name); 267 | $asSetterName = ucwords($asSetterName); 268 | $asSetterName = str_replace(' ', '', $asSetterName); 269 | $asSetterName[0] = strtolower($asSetterName[0]); 270 | $param = (string)(property_exists($this, $asSetterName) ? $asSetterName : ''); 271 | } 272 | 273 | if ($param) { 274 | $reflection = new ReflectionProperty($this, $param); 275 | if ($reflection->isPublic()) { 276 | $this->$param = $value; 277 | $found = true; 278 | } 279 | } 280 | 281 | if (!$found) { 282 | $methodName = str_replace('_', ' ', $name); 283 | $methodName = ucwords($methodName); 284 | $methodName = str_replace(' ', '', $methodName); 285 | $methodName = 'set'.$methodName; 286 | 287 | if (method_exists($this, $methodName)) { 288 | $reflection = new ReflectionMethod($this, $methodName); 289 | if ($reflection->isPublic()) { 290 | $this->$methodName($value); 291 | } 292 | } 293 | } 294 | } 295 | 296 | return $this; 297 | } 298 | 299 | /** 300 | * Magic setter 301 | * 302 | * This method should never be called directly from outside of the class. 303 | * 304 | * @param string $name 305 | * @param mixed $value 306 | * 307 | * @return void 308 | * @throws ReflectionException 309 | * @throws Exception 310 | */ 311 | public function __set($name, $value) 312 | { 313 | $methodName = 'set'.ucfirst($name); 314 | if (!method_exists($this, $methodName)) { 315 | $this->addToRegistry($name, $value); 316 | } else { 317 | $method = new ReflectionMethod($this, $methodName); 318 | if ($method->isPublic()) { 319 | $this->$methodName($value); 320 | } 321 | } 322 | } 323 | 324 | /** 325 | * Magic getter 326 | * 327 | * This method should never be called directly from outside of the class. 328 | * 329 | * @param string $name 330 | * 331 | * @return mixed 332 | * @throws ReflectionException 333 | * @throws Exception 334 | */ 335 | public function __get($name) 336 | { 337 | $methodName = 'get'.ucfirst($name); 338 | if (!method_exists($this, $methodName) && $this->getRegistry()->contains($name)) { 339 | return $this->getRegistry()->itemAt($name); 340 | } elseif (method_exists($this, $methodName)) { 341 | $method = new ReflectionMethod($this, $methodName); 342 | if ($method->isPublic()) { 343 | return $this->$methodName(); 344 | } 345 | } 346 | } 347 | } 348 | -------------------------------------------------------------------------------- /MailWizzApi/Cache/Abstract.php: -------------------------------------------------------------------------------- 1 | 8 | * @link https://www.mailwizz.com/ 9 | * @copyright 2013-2020 https://www.mailwizz.com/ 10 | */ 11 | 12 | 13 | /** 14 | * MailWizzApi_Cache_Abstract is the base class that all the caching classes should extend. 15 | * 16 | * @author Serban George Cristian
Directory access is forbidden.
8 | 9 | 10 | -------------------------------------------------------------------------------- /MailWizzApi/Config.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | 11 | /** 12 | * MailWizzApi_Config contains the configuration class that is injected at runtime into the main application. 13 | * 14 | * It's only purpose is to set the needed data so that the API calls will run without problems. 15 | * 16 | * @author Serban George Cristian19 | * $map[$key]=$value; // add a key-value pair 20 | * unset($map[$key]); // remove the value with the specified key 21 | * if(isset($map[$key])) // if the map contains the key 22 | * foreach($map as $key=>$value) // traverse the items in the map 23 | * $n=count($map); // returns the number of items in the map 24 | *25 | * 26 | * @property boolean $readOnly Whether this map is read-only or not. Defaults to false. 27 | * @property MailWizzApi_ParamsIterator $iterator An iterator for traversing the items in the list. 28 | * @property integer $count The number of items in the map. 29 | * @property array $keys The key list. 30 | * 31 | * @author Qiang Xue
44 | * $map[$key]=$value; // add a key-value pair 45 | * unset($map[$key]); // remove the value with the specified key 46 | * if(isset($map[$key])) // if the map contains the key 47 | * foreach($map as $key=>$value) // traverse the items in the map 48 | * $n=count($map); // returns the number of items in the map 49 | *50 | * 51 | * @property boolean $readOnly Whether this map is read-only or not. Defaults to false. 52 | * @property MailWizzApi_ParamsIterator $iterator An iterator for traversing the items in the list. 53 | * @property integer $count The number of items in the map. 54 | * @property array $keys The key list. 55 | * 56 | * @author Serban George Cristian 57 | * @link http://www.mailwizz.com 58 | * @copyright 2013-2020 https://www.mailwizz.com/ 59 | * @package MailWizzApi 60 | * @since 1.0 61 | * 62 | * Implementation based on CMapIterator class file from the Yii framework. 63 | * Please see /license/yiiframework.txt file for license info. 64 | */ 65 | class MailWizzApi_Params extends MailWizzApi_Base implements IteratorAggregate, ArrayAccess, Countable 66 | { 67 | /** 68 | * @var array internal data storage 69 | */ 70 | private $_data = array(); 71 | 72 | /** 73 | * @var boolean whether this list is read-only 74 | */ 75 | private $_readOnly = false; 76 | 77 | /** 78 | * Constructor. 79 | * Initializes the list with an array or an iterable object. 80 | * @param mixed $data the intial data. Default is null, meaning no initialization. 81 | * @param boolean $readOnly whether the list is read-only 82 | * @throws Exception If data is not null and neither an array nor an iterator. 83 | */ 84 | public function __construct($data = null, $readOnly = false) 85 | { 86 | if ($data !== null) { 87 | $this->copyFrom($data); 88 | } 89 | $this->setReadOnly($readOnly); 90 | } 91 | 92 | /** 93 | * @return boolean whether this map is read-only or not. Defaults to false. 94 | */ 95 | public function getReadOnly() 96 | { 97 | return $this->_readOnly; 98 | } 99 | 100 | /** 101 | * @param boolean $value whether this list is read-only or not 102 | * @return void 103 | */ 104 | protected function setReadOnly($value) 105 | { 106 | $this->_readOnly = $value; 107 | } 108 | 109 | /** 110 | * Returns an iterator for traversing the items in the list. 111 | * This method is required by the interface IteratorAggregate. 112 | * @return MailWizzApi_ParamsIterator an iterator for traversing the items in the list. 113 | */ 114 | public function getIterator() 115 | { 116 | return new MailWizzApi_ParamsIterator($this->_data); 117 | } 118 | 119 | /** 120 | * Returns the number of items in the map. 121 | * This method is required by Countable interface. 122 | * @return integer number of items in the map. 123 | */ 124 | public function count() 125 | { 126 | return $this->getCount(); 127 | } 128 | 129 | /** 130 | * Returns the number of items in the map. 131 | * @return integer the number of items in the map 132 | */ 133 | public function getCount() 134 | { 135 | return count($this->_data); 136 | } 137 | 138 | /** 139 | * @return array the key list 140 | */ 141 | public function getKeys() 142 | { 143 | return array_keys($this->_data); 144 | } 145 | 146 | /** 147 | * Returns the item with the specified key. 148 | * This method is exactly the same as {@link offsetGet}. 149 | * @param mixed $key the key 150 | * @return mixed the element at the offset, null if no element is found at the offset 151 | */ 152 | public function itemAt($key) 153 | { 154 | return isset($this->_data[$key]) ? $this->_data[$key] : null; 155 | } 156 | 157 | /** 158 | * Adds an item into the map. 159 | * Note, if the specified key already exists, the old value will be overwritten. 160 | * @param mixed $key key 161 | * @param mixed $value value 162 | * @throws Exception if the map is read-only 163 | * 164 | * @return void 165 | */ 166 | public function add($key, $value) 167 | { 168 | if (!$this->_readOnly) { 169 | if ($key === null) { 170 | $this->_data[] = $value; 171 | } else { 172 | $this->_data[$key] = $value; 173 | } 174 | } else { 175 | throw new Exception('The params map is read only.'); 176 | } 177 | } 178 | 179 | /** 180 | * Removes an item from the map by its key. 181 | * @param mixed $key the key of the item to be removed 182 | * @return mixed the removed value, null if no such key exists. 183 | * @throws Exception if the map is read-only 184 | * 185 | * @return mixed 186 | */ 187 | public function remove($key) 188 | { 189 | if (!$this->_readOnly) { 190 | if (isset($this->_data[$key])) { 191 | $value = $this->_data[$key]; 192 | unset($this->_data[$key]); 193 | return $value; 194 | } else { 195 | // it is possible the value is null, which is not detected by isset 196 | unset($this->_data[$key]); 197 | return null; 198 | } 199 | } else { 200 | throw new Exception('The params map is read only.'); 201 | } 202 | } 203 | 204 | /** 205 | * Removes all items in the map. 206 | * 207 | * @return void 208 | * @throws Exception 209 | */ 210 | public function clear() 211 | { 212 | foreach (array_keys($this->_data) as $key) { 213 | $this->remove($key); 214 | } 215 | } 216 | 217 | /** 218 | * @param mixed $key the key 219 | * @return boolean whether the map contains an item with the specified key 220 | */ 221 | public function contains($key) 222 | { 223 | return isset($this->_data[$key]) || array_key_exists($key, $this->_data); 224 | } 225 | 226 | /** 227 | * @return array the list of items in array 228 | */ 229 | public function toArray() 230 | { 231 | return $this->_data; 232 | } 233 | 234 | /** 235 | * Copies iterable data into the map. 236 | * Note, existing data in the map will be cleared first. 237 | * @param mixed $data the data to be copied from, must be an array or object implementing Traversable 238 | * @throws Exception If data is neither an array nor an iterator. 239 | * 240 | * @return void 241 | */ 242 | public function copyFrom($data) 243 | { 244 | if (is_array($data) || $data instanceof Traversable) { 245 | if ($this->getCount()>0) { 246 | $this->clear(); 247 | } 248 | if ($data instanceof MailWizzApi_Params) { 249 | $data = $data->_data; 250 | } 251 | foreach ($data as $key => $value) { 252 | $this->add($key, $value); 253 | } 254 | } elseif ($data !== null) { 255 | throw new Exception('Params map data must be an array or an object implementing Traversable.'); 256 | } 257 | } 258 | 259 | /** 260 | * Merges iterable data into the map. 261 | * 262 | * Existing elements in the map will be overwritten if their keys are the same as those in the source. 263 | * If the merge is recursive, the following algorithm is performed: 264 | *
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // CREATE BOUNCE 29 | $response = $endpoint->create('CAMPAIGN-UNIQUE-ID', array( 30 | 'message' => 'The reason why this email bounced', // max 250 chars 31 | 'bounce_type' => 'hard', // hard, soft or internal 32 | 'subscriber_uid' => 'SUBSCRIBER-UNIQUE-ID' // 13 chars unique subscriber identifier 33 | )); 34 | 35 | // DISPLAY RESPONSE 36 | echo '
'; 37 | print_r($response->body); 38 | echo ''; 39 | -------------------------------------------------------------------------------- /examples/campaigns.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_Campaigns(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getCampaigns($pageNumber = 1, $perPage = 10); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // GET ONE ITEM 29 | $response = $endpoint->getCampaign('CAMPAIGN-UNIQUE-ID'); 30 | 31 | // DISPLAY RESPONSE 32 | echo '
'; 33 | print_r($response->body); 34 | echo ''; 35 | 36 | /*===================================================================================*/ 37 | 38 | // CREATE CAMPAIGN 39 | $response = $endpoint->create(array( 40 | 'name' => 'My API Campaign', // required 41 | 'type' => 'regular', // optional: regular or autoresponder 42 | 'from_name' => 'John Doe', // required 43 | 'from_email' => 'john.doe@doe.com', // required 44 | 'subject' => 'Hey, i am testing the campaigns via API', // required 45 | 'reply_to' => 'john.doe@doe.com', // required 46 | 'send_at' => date('Y-m-d H:i:s', strtotime('+10 hours')), // required, this will use the timezone which customer selected 47 | 'list_uid' => 'LIST-UNIQUE-ID', // required 48 | 'segment_uid' => 'SEGMENT-UNIQUE-ID',// optional, only to narrow down 49 | 50 | // optional block, defaults are shown 51 | 'options' => array( 52 | 'url_tracking' => 'no', // yes | no 53 | 'json_feed' => 'no', // yes | no 54 | 'xml_feed' => 'no', // yes | no 55 | 'plain_text_email' => 'yes',// yes | no 56 | 'email_stats' => null, // a valid email address where we should send the stats after campaign done 57 | 58 | // - if autoresponder uncomment bellow: 59 | //'autoresponder_event' => 'AFTER-SUBSCRIBE', // AFTER-SUBSCRIBE or AFTER-CAMPAIGN-OPEN 60 | //'autoresponder_time_unit' => 'hour', // minute, hour, day, week, month, year 61 | //'autoresponder_time_value' => 1, // 1 hour after event 62 | //'autoresponder_open_campaign_id' => 1, // INT id of campaign, only if event is AFTER-CAMPAIGN-OPEN, 63 | 64 | // - if this campaign is advanced recurring, you can set a cron job style frequency. 65 | // - please note that this applies only for regular campaigns. 66 | //'cronjob' => '0 0 * * *', // once a day 67 | //'cronjob_enabled' => 1, // 1 or 0 68 | ), 69 | 70 | // required block, archive or template_uid or content => required. 71 | 'template' => array( 72 | //'archive' => file_get_contents(dirname(__FILE__) . '/template-example.zip'), 73 | //'template_uid' => 'TEMPLATE-UNIQUE-ID', 74 | 'content' => file_get_contents(dirname(__FILE__) . '/template-example.html'), 75 | 'inline_css' => 'no', // yes | no 76 | 'plain_text' => null, // leave empty to auto generate 77 | 'auto_plain_text' => 'yes', // yes | no 78 | ), 79 | )); 80 | 81 | // DISPLAY RESPONSE 82 | echo '
'; 83 | print_r($response->body); 84 | echo ''; 85 | 86 | /*===================================================================================*/ 87 | 88 | // UPDATE CAMPAIGN 89 | $response = $endpoint->update('CAMPAIGN-UNIQUE-ID', array( 90 | 'name' => 'My API Campaign UPDATED', // optional at update 91 | 'from_name' => 'John Doe', // optional at update 92 | 'from_email' => 'john.doe@doe.com', // optional at update 93 | 'subject' => 'Hey, i am testing the campaigns via API', // optional at update 94 | 'reply_to' => 'john.doe@doe.com', // optional at update 95 | 'send_at' => date('Y-m-d H:i:s', strtotime('+1 hour')), //optional at update, this will use the timezone which customer selected 96 | 'list_uid' => 'LIST-UNIQUE-ID', // optional at update 97 | 'segment_uid' => 'SEGMENT-UNIQUE-ID',// optional, only to narrow down 98 | 99 | // optional block, defaults are shown 100 | 'options' => array( 101 | 'url_tracking' => 'no', // yes | no 102 | 'json_feed' => 'no', // yes | no 103 | 'xml_feed' => 'no', // yes | no 104 | 'plain_text_email' => 'yes',// yes | no 105 | 'email_stats' => null, // a valid email address where we should send the stats after campaign done 106 | ), 107 | 108 | // optional block at update, archive or template_uid or content => required. 109 | 'template' => array( 110 | //'archive' => file_get_contents(dirname(__FILE__) . '/template-example.zip'), 111 | //'template_uid' => 'TEMPLATE-UNIQUE-ID', 112 | 'content' => file_get_contents(dirname(__FILE__) . '/template-example.html'), 113 | 'inline_css' => 'no', // yes | no 114 | 'plain_text' => null, // leave empty to auto generate 115 | 'auto_plain_text' => 'yes', // yes | no 116 | ), 117 | )); 118 | 119 | // DISPLAY RESPONSE 120 | echo '
'; 121 | print_r($response->body); 122 | echo ''; 123 | 124 | /*===================================================================================*/ 125 | 126 | // Copy CAMPAIGN 127 | $response = $endpoint->copy('CAMPAIGN-UNIQUE-ID'); 128 | 129 | // DISPLAY RESPONSE 130 | echo '
'; 131 | print_r($response->body); 132 | echo ''; 133 | 134 | /*===================================================================================*/ 135 | 136 | // Pause/Unpause CAMPAIGN 137 | $response = $endpoint->pauseUnpause('CAMPAIGN-UNIQUE-ID'); 138 | 139 | // DISPLAY RESPONSE 140 | echo '
'; 141 | print_r($response->body); 142 | echo ''; 143 | 144 | /*===================================================================================*/ 145 | 146 | // Mark CAMPAIGN as sent 147 | $response = $endpoint->markSent('CAMPAIGN-UNIQUE-ID'); 148 | 149 | // DISPLAY RESPONSE 150 | echo '
'; 151 | print_r($response->body); 152 | echo ''; 153 | 154 | /*===================================================================================*/ 155 | 156 | // Delete CAMPAIGN 157 | $response = $endpoint->delete('CAMPAIGN-UNIQUE-ID'); 158 | 159 | // DISPLAY RESPONSE 160 | echo '
'; 161 | print_r($response->body); 162 | echo ''; 163 | -------------------------------------------------------------------------------- /examples/campaigns_tracking.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // PLEASE NOTE THAT THIS ENDPOINT ONLY WORKS WITH MAILWIZZ >= 1.3.7.3 14 | // CREATE THE ENDPOINT 15 | $endpoint = new MailWizzApi_Endpoint_CampaignsTracking(); 16 | 17 | /*===================================================================================*/ 18 | 19 | // Track subscriber click for campaign click 20 | $response = $endpoint->trackUrl('CAMPAIGN-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID', 'URL-HASH'); 21 | 22 | // DISPLAY RESPONSE 23 | echo '
'; 24 | print_r($response->body); 25 | echo ''; 26 | 27 | /*===================================================================================*/ 28 | 29 | // Track subscriber open for campaign 30 | $response = $endpoint->trackOpening('CAMPAIGN-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID'); 31 | 32 | // DISPLAY RESPONSE 33 | echo '
'; 34 | print_r($response->body); 35 | echo ''; 36 | 37 | /*===================================================================================*/ 38 | 39 | // Track subscriber unsubscribe for campaign 40 | $response = $endpoint->trackUnsubscribe('CAMPAIGN-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID', array( 41 | 'ip_address' => '123.123.123.123', 42 | 'user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', 43 | 'reason' => 'Reason for unsubscribe!', 44 | )); 45 | 46 | // DISPLAY RESPONSE 47 | echo '
'; 48 | print_r($response->body); 49 | echo ''; 50 | -------------------------------------------------------------------------------- /examples/countries.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_Countries(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getCountries($pageNumber = 23, $perPage = 10); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // get country zones 29 | $response = $endpoint->getZones(223, $pageNumber = 1, $perPage = 10); 30 | 31 | // DISPLAY RESPONSE 32 | echo '
'; 33 | print_r($response->body); 34 | echo ''; 35 | -------------------------------------------------------------------------------- /examples/customers.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_Customers(); 15 | /*===================================================================================*/ 16 | 17 | // CREATE CUSTOMER 18 | $response = $endpoint->create(array( 19 | 'customer' => array( 20 | 'first_name' => 'John', 21 | 'last_name' => 'Doe', 22 | 'email' => 'john.doe@doe.com', 23 | 'password' => 'superDuperPassword', 24 | 'timezone' => 'UTC', 25 | ), 26 | // company is optional, unless required from app settings 27 | 'company' => array( 28 | 'name' => 'John Doe LLC', 29 | 'country' => 'United States', // see the countries endpoint for available countries and their zones 30 | 'zone' => 'New York', // see the countries endpoint for available countries and their zones 31 | 'city' => 'Brooklyn', 32 | 'zip_code' => 11222, 33 | 'address_1'=> 'Some Address', 34 | 'address_2'=> 'Some Other Address', 35 | ), 36 | )); 37 | 38 | // DISPLAY RESPONSE 39 | echo '
'; 40 | print_r($response->body); 41 | echo ''; 42 | -------------------------------------------------------------------------------- /examples/list_fields.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_ListFields(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getFields('LIST-UNIQUE-ID'); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | -------------------------------------------------------------------------------- /examples/list_segments.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_ListSegments(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getSegments('LIST-UNIQUE-ID'); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | -------------------------------------------------------------------------------- /examples/list_subscribers.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_ListSubscribers(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getSubscribers('LIST-UNIQUE-ID', $pageNumber = 1, $perPage = 10); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // GET ONE ITEM 29 | $response = $endpoint->getSubscriber('LIST-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID'); 30 | 31 | // DISPLAY RESPONSE 32 | echo '
'; 33 | print_r($response->body); 34 | echo ''; 35 | 36 | /*===================================================================================*/ 37 | 38 | // SEARCH BY EMAIL 39 | $response = $endpoint->emailSearch('LIST-UNIQUE-ID', 'john.doe@doe.com'); 40 | 41 | // DISPLAY RESPONSE 42 | echo '
'; 43 | print_r($response->body); 44 | echo ''; 45 | 46 | /*===================================================================================*/ 47 | 48 | // SEARCH BY EMAIL IN ALL LISTS 49 | $response = $endpoint->emailSearchAllLists('john.doe@doe.com'); 50 | 51 | // DISPLAY RESPONSE 52 | echo '
'; 53 | print_r($response->body); 54 | echo ''; 55 | 56 | /*===================================================================================*/ 57 | 58 | // SEARCH BY CUSTOM FIELDS IN A LIST 59 | $response = $endpoint->searchByCustomFields('LIST-UNIQUE-ID', array( 60 | 'EMAIL' => 'john.doe@doe.com' 61 | )); 62 | 63 | // DISPLAY RESPONSE 64 | echo '
'; 65 | print_r($response->body); 66 | echo ''; 67 | 68 | /*===================================================================================*/ 69 | 70 | // ADD SUBSCRIBER 71 | $response = $endpoint->create('LIST-UNIQUE-ID', array( 72 | 'EMAIL' => 'john.doe@doe.com', // the confirmation email will be sent!!! Use valid email address 73 | 'FNAME' => 'John', 74 | 'LNAME' => 'Doe' 75 | )); 76 | 77 | // DISPLAY RESPONSE 78 | echo '
'; 79 | print_r($response->body); 80 | echo ''; 81 | 82 | /*===================================================================================*/ 83 | 84 | // ADD SUBSCRIBERS IN BULK (since MailWizz 1.8.1) 85 | $response = $endpoint->createBulk('LIST-UNIQUE-ID', array( 86 | array( 87 | 'EMAIL' => 'john.doe-1@doe.com', 88 | 'FNAME' => 'John', 89 | 'LNAME' => 'Doe' 90 | ), 91 | array( 92 | 'EMAIL' => 'john.doe-2@doe.com', 93 | 'FNAME' => 'John', 94 | 'LNAME' => 'Doe' 95 | ), 96 | array( 97 | 'EMAIL' => 'john.doe-3@doe.com', 98 | 'FNAME' => 'John', 99 | 'LNAME' => 'Doe' 100 | ) 101 | )); 102 | 103 | // DISPLAY RESPONSE 104 | echo '
'; 105 | print_r($response->body); 106 | echo ''; 107 | 108 | 109 | /*===================================================================================*/ 110 | 111 | // UPDATE EXISTING SUBSCRIBER 112 | $response = $endpoint->update('LIST-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID', array( 113 | 'EMAIL' => 'john.doe@doe.com', 114 | 'FNAME' => 'John', 115 | 'LNAME' => 'Doe Updated' 116 | )); 117 | 118 | // DISPLAY RESPONSE 119 | echo '
'; 121 | print_r($response->body); 122 | echo ''; 123 | 124 | /*===================================================================================*/ 125 | 126 | // UPDATE EXISTING SUBSCRIBER BY EMAIL 127 | $response = $endpoint->updateByEmail('LIST-UNIQUE-ID', 'john@doe.com', array( 128 | 'EMAIL' => 'john.doe@doe.com', 129 | 'FNAME' => 'John', 130 | 'LNAME' => 'Doe Updated' 131 | )); 132 | 133 | // DISPLAY RESPONSE 134 | echo '
'; 136 | print_r($response->body); 137 | echo ''; 138 | 139 | /*===================================================================================*/ 140 | 141 | // CREATE / UPDATE EXISTING SUBSCRIBER 142 | $response = $endpoint->createUpdate('LIST-UNIQUE-ID', array( 143 | 'EMAIL' => 'john.doe@doe.com', 144 | 'FNAME' => 'John', 145 | 'LNAME' => 'Doe Updated Second time' 146 | )); 147 | 148 | // DISPLAY RESPONSE 149 | echo '
'; 150 | print_r($response->body); 151 | echo ''; 152 | 153 | /*===================================================================================*/ 154 | 155 | // UNSUBSCRIBE existing subscriber, no email is sent, unsubscribe is silent 156 | $response = $endpoint->unsubscribe('LIST-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID'); 157 | 158 | // DISPLAY RESPONSE 159 | echo '
'; 160 | print_r($response->body); 161 | echo ''; 162 | 163 | /*===================================================================================*/ 164 | 165 | // UNSUBSCRIBE existing subscriber by email address, no email is sent, unsubscribe is silent 166 | $response = $endpoint->unsubscribeByEmail('LIST-UNIQUE-ID', 'john@doe.com'); 167 | 168 | // DISPLAY RESPONSE 169 | echo '
'; 170 | print_r($response->body); 171 | echo ''; 172 | /*===================================================================================*/ 173 | 174 | 175 | // UNSUBSCRIBE existing subscriber from all lists, no email is sent, unsubscribe is silent 176 | $response = $endpoint->unsubscribeByEmailFromAllLists('john@doe.com'); 177 | 178 | // DISPLAY RESPONSE 179 | echo '
'; 180 | print_r($response->body); 181 | echo ''; 182 | 183 | /*===================================================================================*/ 184 | 185 | // DELETE SUBSCRIBER, no email is sent, delete is silent 186 | $response = $endpoint->delete('LIST-UNIQUE-ID', 'SUBSCRIBER-UNIQUE-ID'); 187 | 188 | // DISPLAY RESPONSE 189 | echo '
'; 190 | print_r($response->body); 191 | echo ''; 192 | /*===================================================================================*/ 193 | 194 | // DELETE SUBSCRIBER by email address, no email is sent, delete is silent 195 | $response = $endpoint->deleteByEmail('LIST-UNIQUE-ID', 'john@doe.com'); 196 | 197 | // DISPLAY RESPONSE 198 | echo '
'; 199 | print_r($response->body); 200 | echo ''; 201 | -------------------------------------------------------------------------------- /examples/lists.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // create the lists endpoint: 14 | $endpoint = new MailWizzApi_Endpoint_Lists(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getLists($pageNumber = 1, $perPage = 10); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // get a single list 29 | $response = $endpoint->getList('LIST-UNIQUE-ID'); 30 | 31 | // DISPLAY RESPONSE 32 | echo '
'; 33 | print_r($response->body); 34 | echo ''; 35 | 36 | /*===================================================================================*/ 37 | 38 | // copy a list 39 | $response = $endpoint->copy('LIST-UNIQUE-ID'); 40 | 41 | // DISPLAY RESPONSE 42 | echo '
'; 43 | print_r($response->body); 44 | echo ''; 45 | 46 | /*===================================================================================*/ 47 | 48 | // delete a list 49 | $response = $endpoint->delete('LIST-UNIQUE-ID'); 50 | 51 | // DISPLAY RESPONSE 52 | echo '
'; 53 | print_r($response->body); 54 | echo ''; 55 | -------------------------------------------------------------------------------- /examples/lists_create.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // create the lists endpoint: 14 | $endpoint = new MailWizzApi_Endpoint_Lists(); 15 | 16 | // create a new list 17 | // please see countries.php example file for a list of allowed countries/zones for list company 18 | $response = $endpoint->create(array( 19 | // required 20 | 'general' => array( 21 | 'name' => 'My list created from the API', // required 22 | 'description' => 'This is a test list, created from the API.', // required 23 | ), 24 | // required 25 | 'defaults' => array( 26 | 'from_name' => 'John Doe', // required 27 | 'from_email'=> 'johndoe@doe.com', // required 28 | 'reply_to' => 'johndoe@doe.com', // required 29 | 'subject' => 'Hello!', 30 | ), 31 | // optional 32 | 'notifications' => array( 33 | // notification when new subscriber added 34 | 'subscribe' => 'yes', // yes|no 35 | // notification when subscriber unsubscribes 36 | 'unsubscribe' => 'yes', // yes|no 37 | // where to send the notifications. 38 | 'subscribe_to' => 'johndoe@doe.com', 39 | 'unsubscribe_to' => 'johndoe@doe.com', 40 | ), 41 | // optional, if not set customer company data will be used 42 | 'company' => array( 43 | 'name' => 'John Doe INC', // required 44 | 'country' => 'United States', // required 45 | 'zone' => 'New York', // required 46 | 'address_1' => 'Some street address', // required 47 | 'address_2' => '', 48 | 'zone_name' => '', // when country doesn't have required zone. 49 | 'city' => 'New York City', 50 | 'zip_code' => '10019', 51 | ), 52 | )); 53 | 54 | // and get the response 55 | echo '
'; 56 | print_r($response->body); 57 | echo ''; 58 | -------------------------------------------------------------------------------- /examples/lists_update.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // create the lists endpoint: 14 | $endpoint = new MailWizzApi_Endpoint_Lists(); 15 | 16 | // update list 17 | // please see countries.php example file for a list of allowed countries/zones for list company 18 | $response = $endpoint->update('LIST-UNIQUE-ID', array( 19 | // required 20 | 'general' => array( 21 | 'name' => 'My list created from the API - now updated!', // required 22 | 'description' => 'This is a test list, created from the API.', // required 23 | ), 24 | // required 25 | 'defaults' => array( 26 | 'from_name' => 'John Doe', // required 27 | 'from_email'=> 'johndoe@doe.com', // required 28 | 'reply_to' => 'johndoe@doe.com', // required 29 | 'subject' => 'Hello!', 30 | ), 31 | // optional 32 | 'notifications' => array( 33 | // notification when new subscriber added 34 | 'subscribe' => 'yes', // yes|no 35 | // notification when subscriber unsubscribes 36 | 'unsubscribe' => 'yes', // yes|no 37 | // where to send the notifications. 38 | 'subscribe_to' => 'johndoe@doe.com', 39 | 'unsubscribe_to' => 'johndoe@doe.com', 40 | ), 41 | // optional, if not set customer company data will be used 42 | 'company' => array( 43 | 'name' => 'John Doe INC', // required 44 | 'country' => 'United States', // required 45 | 'zone' => 'New York', // required 46 | 'address_1' => 'Some street address', // required 47 | 'address_2' => '', 48 | 'zone_name' => '', 49 | 'city' => 'New York City', 50 | 'zip_code' => '10019', 51 | ), 52 | )); 53 | 54 | // and get the response 55 | echo '
'; 56 | print_r($response->body); 57 | echo ''; 58 | -------------------------------------------------------------------------------- /examples/setup.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | exit('COMMENT ME TO TEST THE EXAMPLES!'); 11 | 12 | // require the autoloader class if you haven't used composer to install the package 13 | require_once dirname(__FILE__) . '/../MailWizzApi/Autoloader.php'; 14 | 15 | // register the autoloader if you haven't used composer to install the package 16 | MailWizzApi_Autoloader::register(); 17 | 18 | // if using a framework that already uses an autoloading mechanism, like Yii for example, 19 | // you can register the autoloader like: 20 | // Yii::registerAutoloader(array('MailWizzApi_Autoloader', 'autoloader'), true); 21 | 22 | /** 23 | * Notes: 24 | * If SSL present on the webhost, the api can be accessed via SSL as well (https://...). 25 | * A self signed SSL certificate will work just fine. 26 | * If the MailWizz powered website doesn't use clean urls, 27 | * make sure your apiUrl has the index.php part of url included, i.e: 28 | * http://www.mailwizz-powered-website.tld/api/index.php 29 | * 30 | * Configuration components: 31 | * The api for the MailWizz EMA is designed to return proper etags when GET requests are made. 32 | * We can use this to cache the request response in order to decrease loading time therefore improving performance. 33 | * In this case, we will need to use a cache component that will store the responses and a file cache will do it just fine. 34 | * Please see MailWizzApi/Cache for a list of available cache components and their usage. 35 | */ 36 | 37 | // configuration object 38 | $config = new MailWizzApi_Config(array( 39 | 'apiUrl' => 'http://www.mailwizz-powered-website.tld/api', 40 | 'publicKey' => 'PUBLIC-KEY', 41 | 'privateKey' => 'PRIVATE-KEY', 42 | 43 | // components 44 | 'components' => array( 45 | 'cache' => array( 46 | 'class' => 'MailWizzApi_Cache_File', 47 | 'filesPath' => dirname(__FILE__) . '/../MailWizzApi/Cache/data/cache', // make sure it is writable by webserver 48 | ) 49 | ), 50 | )); 51 | 52 | // now inject the configuration and we are ready to make api calls 53 | MailWizzApi_Base::setConfig($config); 54 | 55 | // start UTC 56 | date_default_timezone_set('UTC'); 57 | -------------------------------------------------------------------------------- /examples/template-example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // Search ALL ITEMS (available from MailWizz 1.4.4) 29 | $response = $endpoint->searchTemplates($pageNumber = 1, $perPage = 10, array( 30 | 'name' => 'my template name' 31 | )); 32 | 33 | // DISPLAY RESPONSE 34 | echo '
'; 35 | print_r($response->body); 36 | echo ''; 37 | 38 | /*===================================================================================*/ 39 | 40 | // GET ONE ITEM 41 | $response = $endpoint->getTemplate('TEMPLATE-UNIQUE-ID'); 42 | 43 | // DISPLAY RESPONSE 44 | echo '
'; 45 | print_r($response->body); 46 | echo ''; 47 | 48 | /*===================================================================================*/ 49 | 50 | // delete template 51 | $response = $endpoint->delete('TEMPLATE-UNIQUE-ID'); 52 | 53 | // DISPLAY RESPONSE 54 | echo '
'; 55 | print_r($response->body); 56 | echo ''; 57 | 58 | /*===================================================================================*/ 59 | 60 | // CREATE A NEW TEMPLATE 61 | $rand = rand(); 62 | $response = $endpoint->create(array( 63 | 'name' => 'My API template ' . $rand, 64 | 'content' => file_get_contents(dirname(__FILE__) . '/template-example.html'), 65 | //'archive' => file_get_contents(dirname(__FILE__) . '/template-example.zip'), 66 | 'inline_css' => 'no',// yes|no 67 | )); 68 | 69 | // DISPLAY RESPONSE 70 | echo '
'; 71 | print_r($response->body); 72 | echo ''; 73 | 74 | /*===================================================================================*/ 75 | 76 | // UPDATE A TEMPLATE 77 | $response = $endpoint->update('TEMPLATE-UNIQUE-ID', array( 78 | 'name' => 'My API template - updated' . $rand, 79 | 'content' => file_get_contents(dirname(__FILE__) . '/template-example.html'), 80 | //'archive' => file_get_contents(dirname(__FILE__) . '/template-example.zip'), 81 | 'inline_css' => 'no',// yes|no 82 | )); 83 | 84 | // DISPLAY RESPONSE 85 | echo '
'; 86 | print_r($response->body); 87 | echo ''; 88 | -------------------------------------------------------------------------------- /examples/transactional_emails.php: -------------------------------------------------------------------------------- 1 | 6 | * @link https://www.mailwizz.com/ 7 | * @copyright 2013-2020 https://www.mailwizz.com/ 8 | */ 9 | 10 | // require the setup which has registered the autoloader 11 | require_once dirname(__FILE__) . '/setup.php'; 12 | 13 | // CREATE THE ENDPOINT 14 | $endpoint = new MailWizzApi_Endpoint_TransactionalEmails(); 15 | 16 | /*===================================================================================*/ 17 | 18 | // GET ALL ITEMS 19 | $response = $endpoint->getEmails($pageNumber = 1, $perPage = 10); 20 | 21 | // DISPLAY RESPONSE 22 | echo '
'; 23 | print_r($response->body); 24 | echo ''; 25 | 26 | /*===================================================================================*/ 27 | 28 | // GET ONE ITEM 29 | $response = $endpoint->getEmail('EMAIL-UNIQUE-ID'); 30 | 31 | // DISPLAY RESPONSE 32 | echo '
'; 33 | print_r($response->body); 34 | echo ''; 35 | 36 | /*===================================================================================*/ 37 | 38 | // delete email 39 | $response = $endpoint->delete('EMAIL-UNIQUE-ID'); 40 | 41 | // DISPLAY RESPONSE 42 | echo '
'; 43 | print_r($response->body); 44 | echo ''; 45 | 46 | /*===================================================================================*/ 47 | 48 | // CREATE A NEW EMAIL 49 | $response = $endpoint->create(array( 50 | 'to_name' => 'John Doe', // required 51 | 'to_email' => 'john@doe.com', // required 52 | 'from_name' => 'Jane Doe', // required 53 | 'from_email' => 'jane@doe.com', // optional 54 | 'reply_to_name' => 'Jane Doe', // optional 55 | 'reply_to_email' => 'jane@doe.com', // optional 56 | 'subject' => 'This is the email subject', // required 57 | 'body' => 'Hello world!', // required 58 | 'plain_text' => 'Hello world!', // optional, will be autogenerated if missing 59 | 'send_at' => date('Y-m-d H:i:s'), // required, UTC date time in same format! 60 | )); 61 | 62 | // DISPLAY RESPONSE 63 | echo '
'; 64 | print_r($response->body); 65 | echo ''; 66 | 67 | /*===================================================================================*/ 68 | -------------------------------------------------------------------------------- /php_cs.dist: -------------------------------------------------------------------------------- 1 | exclude('vendor') 5 | ->in('.') 6 | ; 7 | 8 | return PhpCsFixer\Config::create() 9 | ->setRiskyAllowed(true) 10 | ->setRules([ 11 | '@PSR2' => true, 12 | 'array_syntax' => ['syntax' => 'short'], 13 | 'declare_strict_types' => true, 14 | 'no_short_echo_tag' => true, 15 | 'ternary_to_null_coalescing' => true, 16 | 'not_operator_with_successor_space' => false, 17 | 'return_type_declaration' => true, 18 | 'semicolon_after_instruction' => true, 19 | 'short_scalar_cast' => true, 20 | 'single_line_comment_style' => true, 21 | 'single_quote' => true, 22 | 'single_trait_insert_per_statement' => true, 23 | 'space_after_semicolon' => true, 24 | 'standardize_not_equals' => true, 25 | 'standardize_increment' => true, 26 | 'ternary_operator_spaces' => true, 27 | 'trailing_comma_in_multiline_array' => true, 28 | 'trim_array_spaces' => true, 29 | 'unary_operator_spaces' => true, 30 | 'whitespace_after_comma_in_array' => true, 31 | 'combine_consecutive_issets' => true, 32 | 'combine_consecutive_unsets' => true, 33 | 'compact_nullable_typehint' => true, 34 | 'concat_space' => ['spacing' => 'one'], 35 | 'fully_qualified_strict_types' => true, 36 | 'function_typehint_space' => true, 37 | 'include' => true, 38 | 'lowercase_cast' => true, 39 | 'lowercase_constants' => true, 40 | 'lowercase_keywords' => true, 41 | 'lowercase_static_reference' => true, 42 | 'magic_method_casing' => true, 43 | 'method_chaining_indentation' => true, 44 | 'native_function_casing' => true, 45 | 'native_function_type_declaration_casing' => true, 46 | 'new_with_braces' => true, 47 | 'no_empty_statement' => true, 48 | 'no_leading_import_slash' => true, 49 | 'no_mixed_echo_print' => ['use' => 'echo'], 50 | 'no_multiline_whitespace_around_double_arrow' => true, 51 | 'no_null_property_initialization' => true, 52 | 'no_singleline_whitespace_before_semicolons' => true, 53 | 'no_spaces_after_function_name' => true, 54 | 'no_spaces_around_offset' => true, 55 | 'no_spaces_inside_parenthesis' => true, 56 | 'no_superfluous_elseif' => true, 57 | 'no_trailing_comma_in_list_call' => true, 58 | 'no_trailing_comma_in_singleline_array' => true, 59 | 'no_trailing_whitespace' => true, 60 | 'no_unneeded_control_parentheses' => true, 61 | 'no_unneeded_curly_braces' => true, 62 | 'no_unneeded_final_method' => true, 63 | 'no_unset_cast' => true, 64 | 'no_unused_imports' => true, 65 | 'no_useless_else' => true, 66 | 'no_useless_return' => true, 67 | 'no_whitespace_before_comma_in_array' => true, 68 | 'no_whitespace_in_blank_line' => true, 69 | 'normalize_index_brace' => true, 70 | 'object_operator_without_whitespace' => true, 71 | 'ordered_class_elements' => true, 72 | 'ordered_imports' => true, 73 | ]) 74 | ->setFinder($finder) 75 | ; -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | checkMissingIterableValueType: false 3 | checkGenericClassInNonGenericObjectType: false 4 | excludes_analyse: 5 | - examples/* 6 | - vendor/* 7 | - MailWizzApi/Test/* -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 |