Integrating Campaign Monitor API With WordPress

1 Comment | This entry was posted on May 04 2011

One of the most enjoyable things in software development is combining different tools or datasets together into one application. Sometimes this is done to build interesting mashups or more usually to automate an otherwise manual task. Is the case of using the Campaign Monitor API is to prevent having to do a repetitive task manually.

The project I have been working on for the last two weeks is a WordPress blog that allows site visitors to subscribe to a section (or category) of the site to be notified when a new post has been added. As with this project it is expected to have many hundreds or thousands of subscribers, it is not feasible to send mail directly from the web server because of the overhead and the potential of having the server black listed by spam prevention services. Therefore Campaign Monitor was chosen to send any new post notifications out to the subscribers via the API.

The Campaign Monitor API is very easy to use and does nearly everything that is possible through the normal web based interface.  For this solution there were three API calls required to achieve the necessary task, 1. add new subscribers to a list; 2. create a new campaign for each new post; and 3. send the campaign to the subscribers in the list.

A WordPress plugin was created to display a form to populate required Campaign Monitor values such as client and list Ids and to define the functions that will execute the tasks. The tasks are broken down as follows:

  1. A new client list was first added manually to the Campaign Manager client. In the site, new subscribers were already being saved to the WordPress wp_users table. A new function was created and called from this block of code to add subscribers to the specified list.
  2. Each time a new post is created, a hook is used to call a function that gathers that post information and creates a new campaign which is assigned to the existing list. However, before this is done a new html campaign (edm) is created from a template but populated with the post’s title and URL so that the link can be clicked in the receivers email client. This URL is supplied in the API call when creating the new campaign.
  3. After the campaign has been created, another function is been called to send it of to all those in the subscriber list.

And it’s done. The API is simple to use and requires little effort to get started. It can be downloaded from Github in 5 popular web development languages and is supplied with sample code. Each call to update or read from the API is achieved with just a handful of lines and can be sent and received in either XML or JSON. The documentation is clear and intuitive.

For more information, visit the website.

Website Build With Flash/HTML Integration

0 Comments | This entry was posted on Dec 15 2009

Last week, we at Sputnik Agency pushed live the site we had been building for our parent company Kit Digital. What I like most about this website is that it required us to include dynamic Flash navigation that had little overhead and to have the flash headers and html update seamlessly without reloading the page.

Project platform

We decided to go with WordPress as the project required a good CMS that was easy for the client to use and was quick and easy to develop.

Flash navigation with little overhead

There are two main flash headers that include navigation. This navigation needed to be dynamic in the way that if new pages were created in WordPress, the flash navigation needed to include these also. Having the navigation work dynamically this way can create an undesirable overhead as generally this would require mulitple calls to the database.

I overcame this by creating WordPress plugins that used hooks to create XML files when pages were added, updated or removed. These XML files included hierarchical page information required by the navigation. Therefore when a page is loaded in the front-end, the Flash would just read the XML file rather than force PHP to make database query requests. This resulted in the pages loading faster and reducing server overhead.

One other benefit of using SWFAddress is that although page loading does not occur, you can still click back through the pages of content you have loaded. The browser will not behave this way with standard content replacement using AJAX.

Seamlessly update flash header and update content

The next task was to allow links (whether clicked from the Flash navigation or HTML navigation) to update the Flash navigation and HTML without reloading the page. This seemed like a very difficult task and something I had not seen before but we managed this using SWFAddress.

Using the SWFAddress Javascript library we could update the URL in the address bar which would trigger both the HTML and Flash to change their behaviour. Once the the change was caught I used jQuery to make a request to another custom WordPress plugin that would pull page content from the database and then update the HTML without needing to reload the page. Clicking on the Flash links did the same.

The end result is a very sleek and fast loading website where the content is completely CMS driven.

To see these pages in action, visit these links: VX Platform, Global.