Campaign Monitor API - Custom Form

951 Views Asked by At

Following on from Campaign Monitors API change I cannot find any documentation to create a custom subscribe form which collects a users email address and automatically adds it to a specific subscriber list.

There is documentation for their API, which I have got working, but nothing I can find about integrating this into a form.

This is based on: https://github.com/campaignmonitor/createsend-php

    <?php

    require_once 'cmp/csrest_subscribers.php';

    $auth = array(
        'api_key' => 'Your API key'
    );
    $wrap = new CS_REST_Subscribers( 'Your list ID', $auth );

    $result = $wrap->add( array(
        'EmailAddress' => 'Subscriber email',
        'Name' => 'Subscriber name',
        'CustomFields' => array(
            array(
                'Key' => 'Field 1 Key',
                'Value' => 'Field Value'
            ),
            array(
                'Key' => 'Field 2 Key',
                'Value' => 'Field Value'
            ),
            array(
                'Key' => 'Multi Option Field 1',
                'Value' => 'Option 1'
            ),
            array(
                'Key' => 'Multi Option Field 1',
                'Value' => 'Option 2'
            )
        ),
        'ConsentToTrack' => 'yes',
        'Resubscribe' => true
    ) );

    ?>

Any help would be appreciated.

0

There are 0 best solutions below