API Samples
We've put together a range of samples in a number of common languages to make integrating with our API as easy as possible. While each sample doesn't cover every method available, they can be adapted quite easily to work for the other methods.
We're continually expanding our range of samples, but if you've put together some code for yourself or a client for a language or a method we haven't covered, get in touch with support and we'll share it here. Right now we have samples in the following languages:
.NET C#
For the .NET samples, we decided to make up a small Visual Studio 2003 project that has a number of pages included which show examples calling some of the different API methods available. The pages use standard ASP.NET controls, and are written using the Code-Behind model. Of course, if you are using a newer version of Visual Studio, the project can be converted up and you will still be able to access the samples.
The intellisense in Visual Studio does a good job of letting you see what methods are available, and the arguments they require, so it's pretty easy to follow the flow of the examples and get the other methods going.
- Download the sample (zip format - 51kb)
PHP
For all those PHP5 developers out there, we've recently had a fantastic submission from Kaiser Shahid of a pretty much complete library of all of our method calls, wrapped up nicely in a single file. It comes complete with documentation and even an example of it's usage right down the bottom. You'll find it under the PHP5 folder in the sample zip, called CampaignMonitor.php. Awesome job Kaiser.
Additionally, there are a couple of sample scripts we've put together in here for both PHP4 and PHP5. We've used the NuSOAP libraries for the PHP4 samples, but feel free to use any other equivalent libraries such as PEAR, to achieve the same results with very little in the way of code changes. For the PHP5 samples, we've simply used the built in SOAP classes.
Making use of the individual documentation pages will show you exactly what arguments you'll and responses you are likely to see, so modifying the scripts for use with other methods should be pretty straight forward.
- Download the sample (zip format - 13kb)
Classic ASP
The Classic ASP samples here don't use any additional tools to make the call to the API - it's just a basic POST of a SOAP envelope, with the appropriate headers included. All of the other methods in the API can be called in the manner of these examples, just check out the SOAP envelope section of their documentation pages to see what they expect to receive.
- Download the sample (zip format - 3kb)
Flash
We've got a couple of sample files from our customers here, showing both a standard subscribe, and a subscribe with custom fields. They assure us they are easy to change should you require the use of one of our other methods.
We didn't have a custom fields example at all to share before Ben and the team from DNA Design stepped up and offered to put one together for us, so thanks for that guys. A big thanks still goes to Nick Lloyd from Stephen Thomas and Greg McMullen for putting together the original Flash sample which is still available in the zip.
- Download the sample (zip format - 978kb)
Perl
Clever Campaign Monitor customer Leon Breedt was kind enough to put together a script for our Subscriber.AddWithCustomFields method. As with all of our other samples, they can be easily modified to be used with any of the other methods. Thanks again Leon.
- Download the sample (zip format - 1kb)
Cold Fusion
We have a basic ColdFusion sample that includes a standards subscribe form and a more complex one supporting custom fields. The sample code will also be easy to modify to adopt any of the other methods supported by the API. It's all you'll need to get started.
- Download the sample (zip format - 2kb)
Ruby
Ruby developer and Campaign Monitor customer Jordan Brock has put together a RubyForge project and some associated documentation to get all those Ruby users out there going. Thanks for that Jordan.