How do you create a list from PHP?

Highlighted
Occasional Participant

How do you create a list from PHP?

our system uses sales tags that are like lists in constant contact.  What I want to let my users do is create new sales tags on my site and that will automattically add a list with the same name on constant contact.


 


I have the sales tag creation down I just need to know how to create a list on CC.


 


Thanks,


 

1 REPLY 1
Highlighted
CTCT Employee

Re: How do you create a list from PHP?

You can find information about creating a contact list here. This would involve making an http POST request to the lists collection uri (https://api.constantcontact.com/ws/customers/{username}/lists) using a Content-Type header with a value of 'application/atom+xml' and including a variation of the following XML in the request body.


We do have a PHP Library that has this capability already, and would just require the following code the create a list in your account, provided you've setup 'ctctWrapper.php' with your Constant Contact credentials.


<?php



include_once('ctctWrapper.php');

$ListsCollection = new ListsCollection(); // Instantiate the ListsCollection class





// Setup list properties

$list = "Your list name"; // Name of List to create

$list = "99";       // Sort order of list

$list = false;   // Opt in default for 'Join My Mailing List' form



// Create the List Object

$myList = new ListObj($list);



// Add the new list to your Constant Contact account

$ListsCollection->createList($myList);



?>

I hope this helps. If you have any questions regarding this please let us know.

David J

Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured