We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Adding a Contact: from the Contact form on my Site not working....

Regular Participant

Adding a Contact: from the Contact form on my Site not working....


I require help regarding adding a contact from my contact form. Whenever a user registers there he/she should be added in the list of CC automatically at my account. I have used php wrapper cc_class.php my PHP version is 5.2.6. When I run it on my local server it works fine PHP version at local is 5.3.4. But when I upload it on live server first it was giving a Blank page regarding the contact form at there... Now it shows it but did not add contact to list at CC.I just have three fields to add username, lastname and email address...
I have tried and search a lot but could figure out what the problem is? Is there anything wrong with cc_class.php or some issue at Cpanel. Or its some XML related..??
my code is as:

<?php include_once('cc_class.php');
$ccContactOBJ = new CC_Contact();
$ccListOBJ = new CC_List(); 

if (!empty($_POST)) {
$postFields = array();
$postFields["email_address"] = $_POST["email_address"];
$postFields["first_name"] = $_POST["first_name"];
$postFields["last_name"] = $_POST["last_name"];

$postFields["lists"] = 'http://api.constantcontact.com/ws/customers/xxxxxxxxxx/lists/13';

$contactXML = $ccContactOBJ->createContactXML(null,$postFields);

if (!$ccContactOBJ->addSubscriber($contactXML)) {
$error = true;
} else {
$error = false;
$_POST = array();


//get all available lists for the current CC account.
$allLists = $ccListOBJ->getLists();
//get all available states


Hey Dominic,

I am a little unclear of which version of PHP is running on your live server.  Your code looks fine.  How ever I would suggest doing a <?php phpinfo(); ?> in a blank page to find out which version you are running.

Please let me know what version is running so we can find out whats going on.

Ryan Davis
Quality Engineer
Regular Participant

Thanx for your reply....


On live server its PHP version is 5.2.6. and on my local server it is PHP version at local is 5.3.4.

Hey Dominic,


On the live server is cURL enabled?

Ryan Davis
Quality Engineer
Regular Participant

Hey Ryan,


Well I think its enabled..... Because when I use a test page of just containing the username, email it sends the email to constant contract on live server...

I am using XML in my origional php file where the actual form is from where contact details have to be sent. First it was returning a blank where the cc_class is included.... After some tiredly work it does not give blank page...

Well my question was Is there anything wrong with cc_class.php. Or its some XML related..?? as i am using XML in origional file also..... One thing more when I implement in another page (not a test page) it gives the same result i.e, not sending details to CC list.

I am really confused and tired of searching this..... please if you can suggest some simple code or some other class or way according to PHP 5.2.6.. so that it may go in right way........

Thank You for your answers again....

Regular Participant

This may be a silly comment but is the list ID # '13' the correct ID # for the list you have created on your account?  I'd just make sure it is a valid list ID #.

Regular Participant

Yes Susan its valid #

Hey Dominic,


I am unsure why you would have issues between the live and local environement like this.  I would suggest trying to use one of our newwer wrappers that we are going to be switching to. Below is my sample code on how to change a contact.


include ('wrapper/ConstantContact.php');

	$ConstantContact = new ConstantContact("basic", "api-key", "username", "password");

	//Get potential contact lists
	$lists = $ConstantContact->getLists();
        //In your case you will need to do a print_r the first time to see which list is list 13 
        // print_r($lists[lists]);
	$contactObj = new Contact();
        //you only need the array if your are adding to multiple lists
	$contactObj->lists = array($lists['lists'][0]->id, $lists['lists'][1]->id);
	$contactObj->emailAddress = 'test@example.com';
	// Create the contact
	$Contact = $ConstantContact->addContact($contactObj);

 You can find the files to this wrapper here.


Ryan Davis
Quality Engineer
Regular Participant

Thank you...


I will let you know after implementing the new wrapper.

Developer Portal

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

Visit Page