PHP Wrapper: Update subscriber (including CustomFields)

I'm trying to update subscribers using the php wrapper. I've used the samples from Github. The strange thing is: I can get all my active subscribers from a list, but updating them won't work..

Here's my code (with some example data). I only want to update the CustomFields.

$auth = array('api_key' => $API_KEY);
$wrap = new CS_REST_Subscribers($listID, $auth);
$result = $wrap->update('email@example.com' , array(
    'CustomFields' => array(
        array(
            'Key' => 'ID',
            'Value' => '12x3'
        )
    )
));
terryt terryt, 1 year ago

Hi GJTMD,

You'll likely need the Name, EmailAddress and Resubscribe fields in order to run this update. Have a look at https://www.campaignmonitor.com/api/subscribers/#updating_a_subscriber or https://github.com/campaignmonitor/createsend-php/blob/master/samples/subscriber/update.php for an example.

We should be sending back a message about why the call did not work. Would you be able to share the error message?

Cheers,
Terry Tice
Support Engineer


Terry Tice
Campaign Monitor
GJTMD, 1 year ago

Hi Terry

Apperently I had forgotten to include

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

.
Problem solved!

GJTMD

terryt :

Hi GJTMD,

You'll likely need the Name, EmailAddress and Resubscribe fields in order to run this update. Have a look at https://www.campaignmonitor.com/api/subscribers/#updating_a_subscriber or https://github.com/campaignmonitor/createsend-php/blob/master/samples/subscriber/update.php for an example.

We should be sending back a message about why the call did not work. Would you be able to share the error message?

Cheers,
Terry Tice
Support Engineer

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098