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.

constant contact php api works on linux server but not windows server need help

Frequent Participant

constant contact php api works on linux server but not windows server need help

I have a windows hosting server which my client hosts her php based website on. 

I am trying to use the below code to insert a contact into the constant contact account.

The windows server does have curl  installed 


when I check if curl is installed 

via doing a var_dump(curl_version());

I get the below which shows me curl is installed

array(9) {
  string(6) "7.21.0"
  string(13) "i386-pc-win32"
  string(14) "OpenSSL/0.9.8q"
  string(5) "1.2.3"
  array(16) {
    string(4) "dict"
    string(4) "file"
    string(3) "ftp"
    string(4) "ftps"
    string(4) "http"
    string(5) "https"
    string(4) "imap"
    string(5) "imaps"
    string(4) "ldap"
    string(4) "pop3"
    string(5) "pop3s"
    string(4) "rtsp"
    string(4) "smtp"
    string(5) "smtps"
    string(6) "telnet"
    string(4) "tftp"


The php code I am using which I know works on a LAMP server but can not figure out why its not working on my windows server with php installed is

// Instantiate CC_Contact class
$date = date("Y-m-d\TH:i:s");

/////////// REGISTER EMAIL WITH CONSTANT CONTACT ///////////////////
$UN = "******";
$PW = "******";
$Key = "******";
$entry = $theXml = <<<THE__XML

<entry xmlns="http://www.w3.org/2005/Atom">

<title type="text"></title>




<summary type="text">Contact</summary>

<content type="application/vnd.ctct+xml">

<Contact xmlns="http://ws.constantcontact.com/ns/1.0/">



<ContactList id="http://api.constantcontact.com/ws/customers/********/lists/**" />




// Initialize the cURL session
$request ="https://api.constantcontact.com/ws/customers/*******/contacts";
$session = curl_init($request);
// Set up digest authentication
$userNamePassword = $Key . '%' . $UN . ':' . $PW ;
// Set cURL options
curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS , $entry);
curl_setopt($session, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));
curl_setopt($session, CURLOPT_HEADER, false); // Do not return headers
curl_setopt($session, CURLOPT_RETURNTRANSFER, 0); // If you set this to 0, it will take you to a page with the http response
// Execute cURL session and close it
$response = curl_exec($session);
//End adding contact to constant contact



I am hoping someone will have a suggestion for me. Again I know php is working because I have a website written in php that works fine  thanks




Hello Jason,


I have reviewed your code and it appears that the most likely source of your problem is this code :

<id>data&colon;,none</id> which should be <id>data&colon;,none</id>.


An additional step to look into is this is not to case is to try adding this CURL option:

curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0);


If adding that as a CURL option is the resolution to your issue then you are likely having an issue becuase your server has outdated SSL certificates and is unable to verify the certificate for  https://api.constantcontact.com.


If you continue to experience an error it would be a great help to have the error message or more detail about the error itself.



Elijah G.
API Support Engineer
Occasional Participant



Thanks now I copy and pasted that id line to replace what I had and I get the below error


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



Hello Chris,


It appears the issue with the <id>data&colon;,none</id> is that the forum software is convering the colon into the HTML entity code for a colon. I have done a bit more work with the XML and after changing the &colon; back to a normal colon your XML should work.


If it does not you may want to try changing <ContactList id="http://api.constantcontact.com/ws/customers/********/lists/**" /> to <ContactList id="http://api.constantcontact.com/ws/customers/********/lists/**" ></ContactList>



Elijah G.

Tier 2 Support

Elijah G.
API Support Engineer
Developer Portal

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

Visit Page