Problem with subscriberAddWithCustomFields

Hi There,
I am having an issue with using the PHP CMBase wrapper. it seems when I add 5 or more custom fields to the array there is an issue. While the return is success the user is not added. Furthermore there is an error returned on the page:
"Notice: Undefined index: Subscriber.AddWithCustomFieldsResponse in /clientdata/www/au/a/ on line 305"

I have tried to include the minor alteration I made to the example file below. This is based on 1.4.3, downloaded within the hour.

Any assistance appreciated:)

    //Sample using the CMBase.php wrapper to call Subscriber.AddWithCustomFields from any version of PHP
    //Relative path to CMBase.php. This example assumes the file is in the same folder
    //Your API Key. Go to to see where to find this and other required keys
    $api_key = '...';
    $client_id = null;
    $campaign_id = null;
    $list_id = '...';
    $cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );
    //Optional statement to include debugging information in the result
    //$cm->debug_level = 1;
    //This is the actual call to the method, passing email address, name and custom fields. Custom fields should be added as an array as shown here with the Interests and Dog fields.
    //Multi-option field values are added as an array within this, as demonstrated for the Interests field.
    $result = $cm->subscriberAddWithCustomFields('', 'Joe Smith', array('Foo1' => 'poo1','Foo2' => 'poo2','Foo3' => 'poo3','Foo4' => 'poo4','Foo5' => 'poo5'));

    if($result['Code'] == 0)
        echo 'Success';
        echo 'Error : ' . $result['Message'];
    //Print out the debugging info
Phil Phil, 7 years ago


For others reading who are having a similar problem to jasjc, we resolved this issue after a little back and forward in a support request.

Turns out that jasjc's network configuration was causing problems for cURL, and the easiest thing to do was simply disable cURL in his wrapper. This is easily done by inserting a couple of lines after instantiating the CampaignMonitor object:

$cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );
$cm->curl = false;
$cm->curlExists = false; // both of these aren't necessary, but it doesn't hurt

If you have multiple CM objects, it might be neater to modify the CMBase initializing lines and/or constructor  to achieve the same affect.

Hope that helps,

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free