Simple AS3 class to add subscribers via MailChimp API 3.0


Share:

Making Apps and Taking Names

We needed to allow email subscriptions to a MailChimp list for a recent cross platform Adobe Air project (Android/iOS), so put this purpose built class together to do the job. Happily, with this particular functionality we didn’t need to get involved with OAuth because basic access authentication via HTTP headers are allowed.

Data collection is obviously really handy to have and MailChimp makes the process very easy, sidestepping the need to have your own server and database up and running to do so. Really happy to say it was quick and simple to set up.

It’s very far from being a complete wrapper for the MailChimp API but if all you want to do is a simple sign up form, it’ll do the job!

Download Here: MailChimp Add Subscribers Class for AS3

Usage:

MailChimp.addSubscriber("[email protected]")

Additionally you can add handler functions for the success and/or for the fail events:

MailChimp.addSubscriber("[email protected]", doComplete, doError)

function doComplete(e:Event):void {
   var myLoader:URLLoader = e.currentTarget as URLLoader
   myLoader.removeEventListener(IOErrorEvent.IO_ERROR, doError);
   myLoader.removeEventListener(Event.COMPLETE, doComplete);
   trace("MAIL CHIMP - Subscriber added")
}

function doError(e:IOErrorEvent):void {
   var myLoader:URLLoader = e.currentTarget as URLLoader
   myLoader.removeEventListener(IOErrorEvent.IO_ERROR, doError);
   myLoader.removeEventListener(Event.COMPLETE, doComplete);
   trace("MAIL CHIMP ERROR - " + URLLoader(e.currentTarget).data)
}

Learn more about our Sydney App Developer services.

Share:


    Creative Digital Agency

    Code and Visual works with clients around Australia to create and build outstanding and accessible digital services. If you want to discus a project contact us now for an initial consultation.


    Categories

    Recent Posts