I managed to get this working, code below if it can help anyone else:
<?php
require_once '../../csrest_subscribers.php';
$Subscription = $hook->getValue('Subscription');
if ( $Subscription == Yes ) {
echo
$wrap = new CS_REST_Subscribers('{list id}', '{api key}');
$result = $wrap->add(
$allFormFields = $hook->getValues(array(
'EmailAddress' => 'EmailAddress',
'Name' => 'Name',
'CustomFields' => array(
array(
'Key' => 'Field Key',
'Value' => 'Field Value'
)),
'Resubscribe' => true
))
);
} else {
echo "";
}
This hook adds users to a campaign monitor list using a form on my website. They will only be added if they selected a 'subscription' check box which passes a value of 'Yes'.
This uses the Campaign Monitor API and the PHP Wrapper available from their website. You will need to change the list id and api key to your own.
If any one has any improvements to this code please let me know
Thanks