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.

populating sent_to_contact_lists

Frequent Participant

populating sent_to_contact_lists

I am using PHP to create and schedule an email campaign.


I have it almost done. It works fine without a contact list being assisgned to it.


I am getting hung up on how to populate $campaign->sent_to_contact_lists with the name of the list I want to send to


I do not use a form. I know the name of the list I want to send to. It is predetermined. Let's say for the sake of discussion its "test".


How do I create the necessary object and assign it to $campaign->sent_to_contact_lists


To successful attach and list to my email campaign.


Thanks in advance for your assistance.


You need to supply one or more ContactList objects (https://github.com/constantcontact/php-sdk/blob/development/src/Ctct/Components/Contacts/ContactList...) to the array of lists to send the campaign to.  You can do this by either hard-coding the lists with the ID (that's the only required information) or by pulling the lists, selecting the appropriate ones from the returned collection dynamically and adding them real time.  If you are always going to use the same lists, I'd recommend hard coding the ID value(s). 


Since the name of a list can be changed at any time, we reference the lists by their permanent ID value.  You can retrieve the IDs for all the lists in your account using the getLists() method.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page