Create Contact Issue

Regular Participant

Create Contact Issue



I am trying to create a new contact using code  1.7.2. I am using the code


$contact_list = 0;
 $extra_fields = array(
        'FirstName' => 'Firstname',
        'LastName' => 'Lastname',

$email ="";
$cc = new cc('username', 'pwd');

$new_id = $cc->create_contact($email, $contact_list,$extra_fields);


No contact is added to the default list. Can you please help?


Hi AnupriyaS,


What kind of error are you recieving when your trying to use that code?



Ryan Davis
Quality Engineer
Regular Participant

I am not getting any kind of errors when this code is executed. The response body is blnak.

I am now trying it directly. But getting a 404 error. Can you please help?


            $userNamePassword = $Key . '%' . $UN . ':' . $PW ;

            $entry = '<entry xmlns="">
            <title type="text">Contact: '.$email.'</title>
            <content type="application/vnd.ctct+xml">
            <Contact xmlns="" id="'.$UN.'/contacts/'.$SubID.'">

           $tmpfile = tmpfile();
           fwrite($tmpfile, $entry);
           fseek($tmpfile, 0);

           // Initialize the curl session
           $request ="".$UN."/contacts/".$SubID;
           $session = curl_init($request);

           // Set up Digest authentication. Put your API key, and CTCT username/pwd here
           $userNamePassword = $Key . '%' . $UN . ':' . $PW ;

           curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
           curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);
           curl_setopt($session, CURLOPT_INFILE, $tmpfile);
           fclose($tmpfile); // Close temp file because it no longer needed

           curl_setopt($session, CURLOPT_PUT, 1);
           curl_setopt($session, CURLOPT_INFILESIZE, strlen($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);
           curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0);
           $response = curl_exec($session);
           $httpcode = curl_getinfo($session, CURLINFO_HTTP_CODE);

             echo("httpcode error is ".$httpcode);
             if ($httpcode > 199 && $httpcode < 300){
                 return 'Success';
                 return 'False';

Hi AnupriyaS,


I notied that you have resolved your issue on another post on the baords.  Are you still having any issues creating a new contact?



Ryan Davis
Quality Engineer
Developer Portal

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

Visit Page