March 24, 2009 - 4 comments

Constant Contact RESTful API and Perl


Constant Contact can be a pretty powerful tool that you can use to spam maintain contact lists for newsletter mailings.  They've just released a RESTful API for manipulating lists and contacts, which is a step up from their old form-driven site vistor API.  It's still pretty tough to use, though, and there is not nearly enough documentation for utilizing it with Perl (although they offer code that implements it with PHP and Java).

After some digging, Matt and I found out there's a known bug with Perl's LWP::Authen::Digest module, which is required since the Constant Contact's RESTful API requires Digest authentication. We circumvented the bug by correcting it in our own version of the module.

Although the RESTful API provides more functionality, all we needed was some plain-Jane adding to different contact lists for people requesting to be on a newsletter. With their old API, all the developer had to do was make a POST request to a certain URL, setting several key variables such as username, password, and requested list. The RESTful API mucks up things a bit, though. The biggest difference is that instead of POSTing several variables, the developer has to not only send a whole ATOM entry object, but must either make a POST, GET, or PUT request, depending on the nature of the operation. Oy. In our case, we ran up against the case when an email address had once been in user's Constant Contact lists, but had been removed. The email address doesn't get truly removed; rather it remains in that system with the status set to 'Removed'. This matters, since when adding a new Contact, the request must be a POST, but for an existing user, the request must be a PUT. Constant Contact outlines the gory details on their developer site.

In a word, implementing the RESTful Constant Contact API was a pain, owing to shortcomings of our own technology (Perl) and the convoluted nature of Constant Contact's new API. If anything, it's a lesson in how design deficiencies can turn developers away from your technology if you haven't accounted for their platform.

Published by: Greg Baugues in Business, Developers
Tags: ,


March 25, 2009 at 12:40 pm

Did we push our fixes back out for general use?

March 25, 2009 at 12:42 pm

The bug report linked above suggests the fix we implemented.

March 25, 2009 at 1:25 pm

Tangentially, has anyone seen

If nothing else, they have the prettiest demo video I’ve ever seen.

March 30, 2009 at 3:09 pm

I love mailchimp, I use it for my personal website marketing. They are hillarious. On another note, I am so glad that you guys (Table XI) actually care about these very techie things – so that we don’t have to worry about it! Nice.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.