What version of ConstantContact wrapper will work with PHP version 4.3.11?

Regular Participant

What version of ConstantContact wrapper will work with PHP version 4.3.11?

For some reason, the following statement does not work (does not return).


include ('wrapper/ConstantContact.php');


Does any one have any suggestion on how to fix it?


My web-site is hosted by YAHOO.

My PHP version is 4.3.11.

This is very old PHP.


What version of ConstantContact wrapper will work with PHP version 4.3.11? 

Where I can down load such ConstantContact wrapper?


In http://sourceforge.net/projects/ctctphplib/files/ , there are three ZIP files.

Which one will work with PHP version 4.3.11?






Unfortunately we don't provide a version of our wrapper that works with anything below PHP 5.  I do believe you can switch the version of PHP on your yahoo site by following the instructions in that link though.  


Thank you for contacting Constant Contact, and have a wonderful day!


Best Regards,

Shannon W.

API Support Specialist

Regular Participant

Hi Shannon_W:


Thanks for help.


I was able to switch my PHP version to 5.3.

After that, I was able to add a NEW contact successfully using the codes shown below.


HOWEVRE, I retried it again to add the SAME contact, I go the following error message:


"was added to your new listd”


“Constant Contact HTTP Request Exception:

 Error 400: The request contains errors in the common Atom sections,
 which lie outside or , such as , , or ."


Any suggestion on how to fix this?


--------------------------------------------------------- ----------------------

Also, I tried following 4 cases, but for all 4 cases, it shows the contact is added by SITE OWNER.


1. Did not set $contactObj->optInSource

2. $contactObj->optInSource    = "ACTION_BY_CUSTOMER";

3. $contactObj->optInSource    = 'ACTION_BY_CUSTOMER';

4. $contactObj->optInSource    = ACTION_BY_CUSTOMER;


What shall I do so that the contact can be shown as added by CONTACT (not SITE OWNER)?

------------ ---------------------------------------------------------------
    /* ================================================= */
    include ('wrapper/ConstantContact.php');

    // Connecting to your account
    $ConstantContact = new ConstantContact("basic", $apikey, $username, $password);

    // Get potential contact lists
    $lists = $ConstantContact->getLists();
    // Lists are returned in multidimentional arrays 0 being the list, and 1 being the next50

    // Search for our new Email address
    $search = $ConstantContact->searchContactsByEmail($emailAddress);

    // If the search didnt return a contact object
    if($search == false)
        echo "Created new contact";

        // Create a new Contact Object to store data into
        $contactObj = new Contact();

        // Adding multiple lists to this new Contact Object
        $contactObj->lists = array($lists['lists'][0]->id, $lists['lists'][1]->id);
        // Set the email address
        $contactObj->emailAddress = $emailAddress;
        // Create the Contact and DONE
        $Contact = $ConstantContact->addContact($contactObj);
        echo $contactObj->emailaddress;

    } // Otherwise we update our existing
        echo $contactObj->emailaddress . " was added to your new list";

        // Gather data from our previous search and store it into a data type
        $contactObj = $ConstantContact->getContactDetails($search[0]);
        // We need to get the old list and add a new list to it as
        // this request requires a PUT and will remove the lists
        // as they are stored in an array
             array_push($contactObj->lists, $lists['lists'][3]->id );
        // Update the contact and DONE
        $UpdateContact = $ConstantContact->updateContact($contactObj);



To make the action show as made by your contact (not the site owner), you should set the OptInSource to ACTION_BY_CONTACT instead of ACTION_BY_CUSTOMER.


As for the error message, the 400 error you are getting indicates that the XML sent to Constant Contact either might not contain everything it should (like a list to subscribe the contact to), or the XML is somehow disorganized, like having a tag inside a tag where it doesn't belong.  I would review the XML that you send to us in the case of a PUT (the contact already existing).  If you'd like to post it here (with your username redacted from the XML), I'd be happy to take a look.



Best Regards,

Shannon W.

API Support Specialist

Regular Participant

How do I know where is the XML file I sent to CC?

How do I find such XML file?

There are functions in our wrapper library classes that convert your contact object to the formatted XML and submit that as the body of the requests made to our API.  the makeRequest function in the CTCTRequest class (Authentication.php file of the wrapper library), is the function that makes the HTTP request via cURL to our API, so you can add code to this function to capture the contents of the $body variable, which should include the formatted XML that is being submitted with your request.


I hope this helps. One you have the XML, we can offer some additional advice or assistance in troubleshooting, if needed.


The first step I would take from your side is to use that XML to create a manual API request using RESTClient. This helpful utility allows you to set up and manually make HTTP requests to REST API services like ours, and it will provide the HTTP status response, and any error message contained in the response body. Wrapper libraries may not pass the response body along to you, and it often contains a more precise message that identified the source of 400 errors.

Mark Coleman
Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page