Simple Add Subscriber code

I have an enquiry form on my website which submits to some php script. How can I use CM's api so that if the user clicks 'subscribe me' checkbox on the enquiry form, their details get added to the subscriber list?

Ive donwlaoded the php api wrapper, got my api key number and list number, but whatever sample code I can find in the wrapper just returns the error "Fatal error: No transport is available"!?

Can anyone show me this very simple code?


jamesd jamesd, 6 years ago

It sounds like the error you are receiving may be to do with your PHP environment, but it is impossible to tell if you cannot identify exactly which line in your code is causing the error. It would help if you could debug your code and identify where the error is occurring.

Assuming you are using the PHP client library, you need to so something similar to the following, using the values you collect in your subscribe form:

require_once '../../csrest_subscribers.php';

$wrap = new CS_REST_Subscribers('Your list ID', 'Your API Key');
$result = $wrap->add(array(
    'EmailAddress' => '',
    'Name' => 'Example Subscriber',
    'CustomFields' => array(),
    'Resubscribe' => true
iamirm, 4 years ago

This answer helped me out a lot. Thanks!

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free