Campaign Monitor API Using PHP and SOAP

Published: 2009-11-17

Campaign Monitor has a fairly comprehensive API and support docs.  Unfortunately there doesn't appear to be many PHP code snippets out there for people to learn from.  This rather quick example should help you understand the basics of a SOAP call to the API.  It's a case of trawling through the WSDL and docs to get the correct method calls and parameters to pass along.

$client = new SoapClient("http://api.createsend.com/api/api.asmx?wsdl",
array('trace'=>true,'exceptions'=>true));

$param['ApiKey'] = "API_KEY";
$param['ListID'] = "LIST_ID";
$param['Email'] = "email@email.com";

try{
$response = $client->AddSubscriberWithCustomFields($param);
}
catch(Exception $e){
echo 'Caught exception: ', $e->getMessage();
}

var_dump($response);

More from this section

RECENT ARTICLES

Lightweight blog created on Ruby/GAA/Datastore stack

Put this together a month or two back but never got around to replaci... read more

Using Node JS and Couch DB Stack for Web Dev

With the recent hype surrounding Node.js I thought I'd better get my ... read more

Campaign Monitor API Using PHP and SOAP

Campaign Monitor has a fairly comprehensive API and support docs.&nbs... read more

Google Maps Snippet

Absolute bare basics when it comes the Google Map api but a snippet o... read more

CREDITS

powered by php-wax the php framework