PHP Wrapper: Delete user by email address

Regular Participant

PHP Wrapper: Delete user by email address

I'm trying to delete a user by email address using the PHP wrapper and I am having trouble.  I think I'm close.  Here is what I have so far:


$ConstantContact = new ConstantContact("basic", "apikey", "usr", "pwd");
// Search for a contact by Email Address
$search = $ConstantContact->searchContactsByEmail('');
// Get details for the Contact
$Contact = $ConstantContact->getContactDetails($search[0]);	
// Delete the contact returned above
$delete = $ConstantContact->deleteContact(***what goes here?***);

I'm having trouble figuring out what goes in the last line to actually delete (unsubscribe) the user?


On this subject, I know there are some very basic examples here but there isn't a whole lot of documentation overall that I'm seeing, and the examples are kind of limited in scope.  Is it somewhere else that I'm missing?  Thanks!


Hey Jeff,


In the wrapper itself there is some documentation which willt ell you what you need.

     * Delete a contact
     * @param Contact $Contact - Contact
     * @return bool
    public function deleteContact(Contact $Contact){
        $ContactsCollection = new ContactsCollection($this->CTCTRequest);
        return $ContactsCollection->deleteContact($this->CTCTRequest->baseUri.$Contact->link);

What you want to do is pass it a Contact Object.  When you do the searchContactsByEmail it will give you back an array of objects. Thats why when you use [0] it will grab the first (in this case the only) object that is returned. 


	$SearchContact = $ConstantContact->searchContactsByEmail('');
	$DeleteContact = $ConstantContact->deleteContact($SearchContact[0]);

Please let me know if this fixes your issue.

Ryan Davis
Quality Engineer
Developer Portal

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

Visit Page