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.

Error adding contact to list

LaurenH69
Regular Participant

Error adding contact to list

Hi,

 

I am trying to add a contact email to an existing list in CC.  I am using PHP with the wrapper provided by CC.  I have verified the variable being passed as the list ID as coming from the $ConstantContact->getLists(); call.

 

I currently get this error:

 

Constant Contact HTTP Request Exception: Error 400: The new contact must contain at least one valid ContactList

 

Code is:

 

$username = 'xxx';
$apiKey = 'xxx';
$consumerSecret = 'xxx';


$Datastore = new CTCTDataStore();


$sessionConsumer = array(
        'key' => 'xxx',
        'secret' => 'xxx',
        'username' => 'xxx'
    );
$Datastore->addUser($sessionConsumer);


$DatastoreUser = $Datastore->lookupUser($username);
   
if($DatastoreUser){
    $ConstantContact = new ConstantContact('oauth', $apiKey, $DatastoreUser['username'], $consumerSecret);    
}

$Contact = new Contact();
$Contact->emailAddress = "test@test.com";
$Contact->lists = "http://api.constantcontact.com/ws/customers/xxx/lists/1";
$NewContact = $ConstantContact->addContact($Contact);

4 REPLIES 4
Ryan_D
Employee

Hey,

 

Try this :

 

$Contact->lists = array("http://api.constantcontact.com/ws/customers/xxx/lists/1");

 

Ryan Davis
Quality Engineer
LaurenH69
Regular Participant

Thank you, that worked!

 

KarenR711
Participant

Can somebody please update the documentation to reflect this so others don't spend time spinning their wheels like I did before coming the forum for the answer?

Hey Karen,

 

If you are referring to the documentation on github, I am currently in the process of rewriting it all. 

Ryan Davis
Quality Engineer
Developer Portal

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

Visit Page