phpOpenEMM now on github

We recently moved the source code for the PHP – wrapper for the email marketing software OpenEMM to github. It is also available via packagist for easier installation. Feel free to follow, fork and send pull requests!

Links

OpenEMM – control open source mailing software OpenEMM

About OpenEMM

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.

include_once('OpenEMM.class.php');
$openemm = new OpenEMM('openemm.wsdl', 'openemm_user', 'openemm_password');
var_dump($openemm->getSubscriber(6));

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.

Example: $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);

JpGraph – a free php diagram library

Imagine, you have some data that you would like to visualize. But normally this is a really ugly job.
JpGraph is a really easy to use php library that helps you dealing with such problems.

diagram example code

<?php
require_once("jpgraph.php");
require_once("jpgraph_line.php");
$prod=array(12,14,3,8,12,'',7,13,19.5,4);
$graph = new Graph(540,300);
$graph->SetScale('intlin');
$lineplot1=new LinePlot($prod);
$lineplot1->SetFillColor("orange");
$graph->Add($lineplot1);
$graph->Stroke();
?>

results in the following diagram:

JpGraph example for a line plot, generated with PHP

JpGraph example for a line plot, generated with PHP

More information about JpGraph

You can find more information about JpGraph on the homepage of JpGraph. It’s free for non-commercial use; for commercial usage, the author charges little money – compared to other available (commercial) tools.