phpWrapper contact->getLists?

SOLVED
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
CTCT 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
CTCT 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
CTCT 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.

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