The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Adding a contact

Consulting & Training

Adding a contact



I am trying to add contacts via the API, using the PHP wrapper class - with no luck so far.  My code is as follows:


include "cc_class.php";
$ccContactOBJ = new CC_Contact();


$postFields = array();
$postFields["email_address"] = $strEmail;

$postFields["lists"] = 50;

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


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


When I echo the XML being generated from createContactXML() it appears that it's not adding anything from the lists variable to the XML.


Where am I going wrong here???



Re: Adding a contact



In my email reply back to your email, I gave you some different code to use with our main PHP wrapper (what I use), but if you'd like to use this wrapper, can you post the XML that is generated with this code, with your username redacted?  You are trying to add email addresses to list 50 with this code, correct?


Best Regards,

Shannon W.

API Support Specialist

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More