Between 8:00 - 9:00 am ET on 10/25 we need to take our site down to make updates. We recommend logging out before 8:00am ET and not using your account during this time. Thank you for your patience while we make these important updates.

Blank Event object

Regular Participant

Blank Event object

I'm using the ctctWrapper.php file to retrieve a list of Events.  I've successfully retrieved an array of events.  If I print_r the array, I see data in it.

 

When I try to create an Event object from an array item, the resulting Event object has null values throughout.  I can't seem to populate the Event object properly.  

 

Here's the code:

 

$data = new EventCollection();

$events = $data->listEvents();

foreach ($events as $item) {

$event= new Event($item);

print var_dump($event); //currently just dumping the object...all values NULL

}

 

Thanks.

3 REPLIES 3
Employee

Hello,

 

I believe the issue that you are running into is that the Events object that is returned when looking at the listEvents function returns both an array for the events, and an array for the next page of events, as all collections in our API return a set of 50 objects at a time.

 

Here is an example of code that you can use which will list all of your events as objects in an array.

 

<?php
    include_once("ctctWrapper.php");
    $data = new EventCollection();
    $events = $data->listEvents();
    print var_dump($events);
?>


If you have any questions regarding this please let me know.

Benjamin Soder
NOC Analyst
Constant Contact
Regular Participant

How do I access an individual Event object?  I need to loop through and display details on each event in the array.  I'm missing something in the next step.  Thanks!

 

Hello,

 

If you want to loop through each event, you would need to do this:

 

<?php
    include_once("ctctWrapper.php");
    $data = new EventCollection();
    $events = $data->listEvents();
    foreach($events[0] as $event)
    {
        print_r ($event);
    }
?>


You could replace the print_r function for what you would want to do for each instance of $event.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Developer Portal

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

Visit Page