How to retrieve CCB event details

Ever wonder how to retrieve event details for your CCB events?  A question recently came up about how to view an event’s publication status in CCB.  Basically, there was a need to retrieve all events from a certain day that was not published on CCB’s public calendar.

In today’s tutorial, I’ll show you how to retrieve events from a certain day, and we’ll also cover how, and whether or not you’re able to retrieve events based on public calendar settings.

At first glance, one would think it is a trivial task to retrieve a list of events from a certain day and calendar status. Upon further inspection of the CCB API documentation, I now see the issue at hand in how it’s not possible to retrieve a list of events based on public calendar status using the CCB API.

Well, I guess that’s it for this tutorial… it can’t be done.   Just kidding! Let’s get started…

After thinking through a few scenarios, an idea came about from an outside party of why not just look up events submitted a specific person.  I believe the person who originally posed the question had only one person entering events and not publishing the events, yet they want to see what events and their event details the person had entered using the CCB API.

So the original question now restated is how to view a list of events created by a single person using the CCB API.  Now this we can do in a breeze as you’ll see in the code example below.

Simply put, we’re going to create a script that will use today’s date or any date you set combined with the use of a name as the creator to return a list of events.

Retrieving event details using CCB event_profiles service

Using the CCB API documentation, find the event_profiles service.  This will be the service we’ll use to retrieve all of the events.

Using the PHP code below, set the following variables and their respective values:

  • apiService – this should be set to event_profiles
  • modifiedDate – if this value is not set, then ALL events will be returned (don’t forget to set this value).   By default, this variable uses a built-in PHP date method which is set to return the exact year, month and day of when the code is executed.  But if you wanted to manually set a date in the past, simply using the following formate: YYYY-MM-DD.  For example, 2015-07-08 would July 8, 2015.
  • personName – set this value to be a person’s first and last name that created or modified forms.

Parsing event details information

To parse each CCB event profile as contained in the XML response, you’ll need to use XPATH query and the //events/event expression.  So, create the nodes variable and assign it to the rss reference to xpath, passing to xpath the //events/event expression.

The next step you’ll want to take is setting the response_object variable to blank or nothing, and prepare a foreach statement to iterate each node of the nodes variable.

Notice that inside of the foreach statement there is an if statement (see below).  This is where we are comparing the personName variable to the name of the person that created the event.  This will only return event details if both values are equal to one another.

Once inside the if statement, return the following event details concatenated as a string and assigned to the response_object variable: name, description, start date, start time, end time, and creator.  Also, take notice of the type of operator used to concatenate full list of events.

Time to test the event details code

Okay, now open a text editor of your choice and assemble your code, creating and saving an events-details.php file that looks like the codebase below.  You’re now ready to copy, paste and test the file via a web browser or command line, if you know how.

Again, we answered a question although not the original question, yet this tutorial should help you in regards to retrieving event details code.

As a bonus, I’ll create another tutorial showing how to create an excel file for those of us that are more comfortable working with filtering, sorting and pivot tables.  Stay tuned.


Please comment if this tutorial has helped you.