deleteContactFromList

Occasional Participant

deleteContactFromList

Hi guys, I'm trying to use deleteContactFromList() but it doesn't seem to work for me.  

 

Code sample!

 

 

//$active is an array of emails of, you guessed it, active users....
foreach($active as $a_email){ //find the contact... $tmp_cntct = $cc->getContactByEmail(ACCESS_TOKEN, $a_email); if(sizeof($tmp_cntct->results) === 0){ //add this contact to the active list...this code works just fine... $Contact = new Contact(); $Contact->addEmail($a_email); $Contact->addList($ref_active); //where $ref_active is my active list from C.C. $NewContact = $cc->addContact(ACCESS_TOKEN, $Contact); } else{ //user found, remove from non_active list $ctct = $tmp_cntct->results[0]; $cc->deleteContactFromList(ACCESS_TOKEN, $ctct, $ref_nonactive); //<-- Just doesn't work for me :( Help! //$ref_nonactive is a valid constant contact list, why wouldn't this do the job? $ctct->addList($ref_active); $cc->updateContact(ACCESS_TOKEN, $ctct, false); //working as well :/ } }

 

 

Any assistance would be great

12 REPLIES 12
Highlighted
Regular Advisor

Re: deleteContactFromList

Hello,

 

Thanks for posting in the forums.  What response are you getting back from deleteContactFromList()?

 

Andrew B.

API Support, Constant Contact

Highlighted
Occasional Participant

Re: deleteContactFromList

  Thanks for the reply,

 

var_dump of the response: bool(true)

 

 

Highlighted
Regular Advisor

Re: deleteContactFromList

How are you determining that the API call is not working?

Highlighted
Occasional Participant

Re: deleteContactFromList

  I log into my Constant contact account to see the email has not been removed from the list.   In this case, the user is added to my "active" list, but is not removed from my "non_active" list.  

 

  

Highlighted
Regular Advisor

Re: deleteContactFromList

Right now there is a delay in the UI reflecting changes made to an account using the API.  So even though you are correctly removing a contact, it will not change in the UI right away.  There is a defect logged to resolve the issue, but I don't have a time frame for its resolution right now.  The best way to check if a contact has been removed at the moment is to verify it through the API.

Highlighted
Frequent Visitor

Re: deleteContactFromList

  Interesting....any idea how long the delay is?   I ran this code last night (about 16 hours ago)

 

 

  Can you provide a brief example on checking this via the API?

Highlighted
Occasional Participant

Re: deleteContactFromList

Logged me in here from our clients account after I went to check :/

 

Anyway;

 

 **Edit...have written my own check....

Highlighted
Occasional Participant

Re: deleteContactFromList

Confirmed, after using the API to check, the contact still belongs to the list.

 

Is it better to modify the contact->lists directly, then perform updateContact()  ?

 

 

 

 

Highlighted
Regular Advisor

Re: deleteContactFromList

Took a look at the SDK (based on the code, the php sdk).  The deleteContactFromList method needs the contact's id as a parameter as a string.  Can you try passing just the contact id string, instead of the entire $ctct, which looks like a Contact object?

 

Edit:  The contact id is an int, sorry.

Developer Portal

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