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.

Error message from PHP API wrapper class

Occasional Visitor

Error message from PHP API wrapper class

We are using an API wrapper class that was recommended by Cosntnat Contact to send new signups to an account when a web user fills out a form. All of the data is being sent properly, but we have started getting an error whenever the script is used. I am not the developer who did the integration, but am trying to do an initial effort to see if we can figure out the issue easily.


The wrapper class is James Benson's Constant-Contact-API (


What we're getting is a warning that says:

Warning: Creating default object from empty value in cc->get_lists() (line 404 of /path/to/code/constant_contact/


Line 404 is the second line in the code block below:


        if(isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'first'):
            $this->list_meta_data->first_page = $this->get_id_from_link($xml['feed']['link']['2_attr']['href']);
            $this->list_meta_data->current_page = $this->get_id_from_link($xml['feed']['link']['3_attr']['href']);
            $this->list_meta_data->next_page = '';



It looks like it's trying to parse out the returned XML, but the XML tree is different from what was expected. I'm wondering if this might just need a different XML path in the parsing? Is anyone familiar with what the change is?


Thank you for any assistance.

Honored Contributor

Re: Error message from PHP API wrapper class



So I've had some time to do some checking on this, and I was able to find the original code for that wrapper (which was actually created a number of years ago by one of our partners). The cause of the warning is that the member list_meta_data has never been initialized before the code tries to access a member of that object (first_page), so PHP throws a warning to let you know that it's corrected by creating a default object.


You could either suppress the warning so that it doesn't display, or you could modify the wrapper code so that it initializes the list_meta_data object before trying to assign members of the object.


Let me know if you have any questions!



Elijah G.
API Support Engineer
Occasional Visitor

Re: Error message from PHP API wrapper class

Thank you, Elijah! That's very helpful.

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