The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

phpWrapper contact->getLists?

SOLVED
Go to solution
Highlighted
Occasional Contributor

phpWrapper contact->getLists?

how do I get an array of the current lists a contact is signed up for?  tried:

$lists = $contact->getLists();

which just gave me an empty array...

 

Also, please, where are the docs for this wrapper?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Employee

Re: phpWrapper contact->getLists?

Hi,

 

You do not need to get the contact ID before listing the contact details.  The listContactDetails function requires the contact object.  Instead of getting the id, you would just do this:

 

<?php
  include_once("ctctWrapper.php");
  $contacts = new ContactsCollection();
  $search = $contacts->searchByEmail('emailaddress@test.com');
  $contact = $search[0][0];
  $contact = $contacts->listContactDetails($contact);
  $contactLists = $contact->getLists();
  print_r ($contactLists);
?>
 

 

This snippet will give you a printed array of lists for the emailaddress@test.com.  If you have any questions please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact

View solution in original post

4 REPLIES 4
Highlighted
Employee

Re: phpWrapper contact->getLists?

Hello,

 

You can get the lists by pulling the contacts details.  In the phpwrapper you would do a call to the listContactDetails function.  This will list all of the contacts details, which include a field that gives you an array of all the lists the contact is currently on.  You can then call the getLists function on the contact object, and it should return all the lists.

 

If you have any questions, or are still running into an issue, please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Highlighted
Occasional Contributor

Re: phpWrapper contact->getLists?

<?php require_once("ctctWrapper.php");?>
<?php
updateContact($myrecordset);
?>
<?php
function updateContact($newmember){
//get the the user id using search by email   	$contacts = new ContactsCollection();
  		$search = $contacts->searchByEmail($newmember['UserEmail']);
		
		
		//print_r($search); works great 


	if($search){
// if $search then get contact id 	$contactId = $search[0][0]->getId();

//this is where I lose it I think 
	$bobbuttons=$contacts->listContactDetails($contactId);
	print_r($bobbuttons);

}

 Sorry, I'm not getting some basic concepts still...

Highlighted
Employee

Re: phpWrapper contact->getLists?

Hi,

 

You do not need to get the contact ID before listing the contact details.  The listContactDetails function requires the contact object.  Instead of getting the id, you would just do this:

 

<?php
  include_once("ctctWrapper.php");
  $contacts = new ContactsCollection();
  $search = $contacts->searchByEmail('emailaddress@test.com');
  $contact = $search[0][0];
  $contact = $contacts->listContactDetails($contact);
  $contactLists = $contact->getLists();
  print_r ($contactLists);
?>
 

 

This snippet will give you a printed array of lists for the emailaddress@test.com.  If you have any questions please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact

View solution in original post

Highlighted
Occasional Contributor

Re: phpWrapper contact->getLists?

thank you, good sir...that solved it.

 

Once again...are there any sample files or docs for this wrapper?  Without the docs, it is almost easier to use the long methods...almost.

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured