Not long ago, I provided a tutorial that offered the ability and functionality to retrieve a full list of process managers and the total number of processes managed.
Today’s tutorial somewhat builds upon the aforementioned tutorial; however, instead of focusing on process managers, we’ll turn our attention to the CCB API service for queue managers: queue_managers.
Once you complete this tutorial, you’ll be able to view all processes and queues for ALL or specific queue managers, specifically the total number of processes and queues managed.
Nevertheless, let’s dive and get started with today’s tutorial! Open a text editor of your choice, creating, naming, and saving a file named queue_managers.php.
Next, be sure to include the config.php file and necessary comments as included in previous tutorials.
Next, set API service variable value to be queue_managers and its respective parameters.
Although the queue_managers API service has no required parameters, it does have optional parameters to help hone the returned results based on the following:
- process_id – process id (integer) for a specific process
- manager_id – manager id (integer) is a person’s CCB individual id
- queue_id – queue id (integer) for a specific queue
For specific guidelines pertaining to the queue_managers API service, please refer to CCB API documentation.
In the code below, you’ll notice in addition to the managerId variable that I’ve included both processId and queueId variables and their respective values (commented).
Once the necessary variables are defined and binded to their specific CCB parameter via the urlData variable, instantiate the ccbDetails function make a GET request.
Once the response is successfully returned, use the following expression and PHP’s XPATH query method to parse the data: //managers/manager.
The only other item to notice is the queueCount variable. This variable is defined immediately after the response_object variable, and is used to compute the total number of queues managed for an individual (seen a few lines later).
Copy, paste, and modify the code to your liking. In addition, you can list the names for each process and queues along with their respective ids (check CCB Documentation).
<?php /** * Queue Managers List */ // contains resusable globals and functions include("includes/config.php"); $apiService = 'queue_managers'; // CCB api service //$processId = 123; // specific process id $managerId = 44; // specific manager id //$queueId = 789; // specific queue id $urlData = array_filter( array( 'srv' => "$apiService" //,'process_id' => $processId ,'manager_id' => "$managerId" //,'queue_id' => "$queueId" ) ); $rss = ccbDetails('get',$urlData); // transform to XML $nodes = $rss->xpath('//managers/manager'); // xpath for managers $response_object = ''; $queueCount = 0; foreach ($nodes as $node) { $response_object .= $node['id'].' - '.$node->name.' (# of Processes Managed: '.$node->processes['count']; $procs = $node->processes->process; if($procs){ foreach($procs as $idata){ $queueCount =+ $idata->queues['count']; } } $response_object .= ' | # of Queues Managed: '.$queueCount.')'; } echo $response_object; ?>
Save your file, then open it via a web browser. Without any errors, you should see the following display or something that resembles it:
And that’s it for today’s tutorial. Things have been busy lately, but I hope to return with a fresh tutorial next week. Thanks and see you back here next week!