OpenEMM is a email marketing software for advanced and (semi-) professional users. It is possible to control some functionality also via a webservice interface. So interacting with the software is possible from every programming language that supports webservices. The php class available at this page abstracts the webservice methods and provides a nativ php interface.
More information can be found in the webservice documentation available at http://www.openemm.org/downloads.html. Please setup the webservice interface as written in the documentation first before playing with the OpenEMM php class.
Download and license information
Download OpenEMM php class – Release 1.1 / 4 KB / ZIP-compressed / License: MIT
Release 1.1 fixes minor bugs, it has been tested up to OpenEMM 6.0.1. Feedback is always welcome!
The code is also available at https://github.com/incratec/enarionPhpOpenEMM
Usage of OpenEMM php class
It is easy to interact with the OpenEMM email marketing software via the webservice interface through the OpenEMM php class. For example, the following code displays the information of a subscriber with the subcriber id 6 from the OpenEMM application.
$openemm = new OpenEMM('openemm.wsdl', 'openemm_user', 'openemm_password');
This example asumes that the php class file OpenEMM.class.php and the webservice description file openemm.wsdl are located in the same directory as the php script file.
Tipps, tricks and problem solutions
Updating an existing subscriber
Since the webservice interface of OpenEMM does not yet provide an update method for an existing subscriber, a workaround is beeing in the function updateSubscriber used. First, all informatio nof the subscriber are fetched from OpenEMM and then the existing subscriber will be overwritten with a combination of the new values and old values for values, that are not new.
Date format of OpenEMM webservice interface
OpenEMM uses a special date/time format for the webservice interface (see OpenEMM webservice manual, section addSubscriber). To generate this, the function generateDateArray can be used. The first parameter indicates the variable name of the date field, the second param the timestamp in unix format and the 3rd (optional) boolean parameter indicates if the result should also contain time information. This function returns an array containing the date/time information in OpenEMM parameter format. It can be merged with other (e.g. subscriber) values with array_merge.
$openemm->generateDateArray('my_datetime_variable_name', time(), false);
Accessing OpenEMM through a http proxy
Problem: You are running an OpenEMM server in the internet and you would like to access it from your intranet. Between intranet and internet is a http proxy.
Solution: The OpenEMM php class takes an extra argument that is routed directly to PHP when setting up the SOAP connection. There you can setup the http proxy connection settings as described in the PHP documentation.
$soapParameter = array('proxy_host' => "localhost", 'proxy_port' => 8080, 'proxy_login' => "some_name", 'proxy_password' => "some_password");
$openemm = new OpenEMM('openemm.wsdl', 'openemm_user', 'openemm_password', $soapParameter);