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 to a list using php assistance...

Regular Visitor

adding a contact to a list using php assistance...

I downloaded the php wrapper and am having issues modifying the addContact.php....


I basically just need the php code needed to add an email address to list ID 7....


$username = xxx';
$apiKey = 'xxx';
$consumerSecret = 'xxx';
$Datastore = new CTCTDataStore();
$DatastoreUser = $Datastore->lookupUser($username);


$Contact = new Contact();
$Contact->emailAddress = "$email";
$Contact->lists = $lists['lists'][7]->id );

$NewContact = $ConstantContact->addContact($Contact);



the issue has to do with how to set the list to ID 7...




Re: adding a contact to a list using php assistance...

The one piece you're missing is that the lists field in the $Contact object must be an array (since you can have 0 or more lists associated with a Contact).  Just change this line line to:


$Contact->lists = array($lists['lists'][7]->id);


That should be the only change you need, the rest of your code looks quite right.

Dave Berard
Senior Product Manager, Constant Contact
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