We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Error message from PHP API wrapper class


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 (class.cc.php)


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/class.cc.php).


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.




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

Thank you, Elijah! That's very helpful.

Developer Portal

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

Visit Page