API Help for Beginner

I'm looking for a beginners resource for using API's. I find the existing resources in this area on CampaignMonitor.com seem intermediate/expert biased.

Specifically, I would like to know how to use CM wrappers and samples. It would be great if there were step by step instructions after downloading the wrappers.

More specifically, I am looking to create a custom sign-up and login for 'new' clients on a separate website.

roshodgekiss roshodgekiss, 5 years ago

Hi uq, welcome to the forums! Sorry to hear that you're having a little difficulty getting around the API resources on our site. We've offered our docs and wrappers with fairly confident coders in mind and would highly recommend that folks learn the fundamentals of their language of choice - let it be Ruby, PHP etc - before using them for their own projects. There are plenty of tutorials out there to help you and others take these first steps in learning how to create robust code - walk, before you run, as they say.

If you are keen to create a custom sign-up form for new clients, I'd highly recommend you check out Artesano. This is a service for rapidly producing and managing sign-up sites, with little to no coding involved.

All the best, uq! Let us know if you have any questions about the above.


Get in touch with us on Twitter: http://twitter.com/campaignmonitor
We're also on Facebook: http://facebook.com/campaignmonitor
blad, 5 years ago

Hi uq

I found the best way to get familiar with the APIs was to write some very simple scripts in PHP then debug them (I use NetBeans on a Mac). Debugging lets you see inside the objects as the come and go, and use print_r liberally to examine them. One thing to remember, you can hop in and out of the object model at almost any level ie. you can go straight to a subscriber list object if you know the apikey, client id and list id.

First, be mentally aware of the object model (Client, Lists, Subscribers etc).

Then, write code bits like this:

<?php
echo "CM Sandpit - play around with the api, lists and clients";
require_once './csrest_general.php';
require_once './csrest_lists.php';
require_once './csrest_clients.php';
// First things first - create CM object with your unique api key.
$apikey = 'xxxxxxxxxxxxxx';
$CM = new CS_REST_General($apikey);
// Part 2 - get clients from your account
$CMClients = array();
$CMClients = $CM->get_clients();
// Returns [ClientID] => xxxxxxx [Name] => clientname
// Part 3 - Get the first client and the first clients list, show the ID and name.
$myClient = new CS_REST_Clients($CMClients[0]['ClientId'], $apikey);
print_r($CMClients); // use print_r to see what's inside
echo "<br />" ;
echo "The Client List ID is " . $CMClients->response[0]->ClientID . "<br />";
echo  "and the name of the list is " . $CMClients->response[0]->Name . "<br />";
?>

Third: Run and debug your code, putting breakpoints in at the object creation points like:

 $myClient = new CS_REST_Clients($CMClients[0]['ClientId'], $apikey);

Doing it this way, by debugging as you go won't create much useful code, but will get you a good understanding of what's going on in the API. The CM guys have made what seems to me to be a very robust, object oriented model and you may not always access it in its purest OO way - but you can graduate to this when your au-fait with things....
Good luck!

Pete

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098