Documentation
Documentation for my Campaign Monitor CFC Library
Initialising the components
The CFCs can be placed into whatever scope you want, i’d recommend application scope (place in your application.cfc’s OnApplicationStart function.
Or just on a page like so:
<cfscript>
variables.APIKey = 'Your Api Key'
variables.campaign-monitor = CreateObject("component", "path.to.cfc.campaign-monitor").init(variables.APIKey);
variables.subscribers = CreateObject("component", "path.to.cfc.subscribers").init(variables.APIKey);
variables.lists = CreateObject("component", "path.to.cfc.lists").init(variables.APIKey);
variables.clients = CreateObject("component", "path.to.cfc.clients").init(variables.APIKey);
variables.campaigns = CreateObject("component", "path.to.cfc.campaigns").init(variables.APIKey);
variables.templates = CreateObject("component", "path.to.cfc.templates").init(variables.APIKey);
</cfscript>
Making a function call
Once your CFCs are initialised, function calls are as simple as:
<cfscript> variables.structReturned = variables.clients.ListClients(); </cfscript> <cfdump var="#variables.structReturned#">
What is returned?
Different functions return different data, on the whole it will either be a structure or a query.
The structures could/will contain:
<cfoutput> <!--- Always returned, 0 or 1 ---> #variables.structReturned.blnSuccess# <!--- If blnSuccess is false, error code is returned (int) ---> #variables.structReturned.errorCode# <!--- If blnSuccess is false, error message is returned (string) ---> #variables.structReturned.errorMessage# <!--- If blnSuccess is true, a query COULD be returned (depends on function) ---> #variables.structReturned.returnQuery# <!--- If blnSuccess is true, a structure (details,billing) COULD be returned (depends on function) ---> #variables.structReturned.details# <!--- If blnSuccess is true, a string COULD be returned (depends on function) ---> #variables.structReturned.returnString# </cfoutput>
Just dump out the return and see what you get!