Tech Blog

PHP class for Alma webhooks

Instead of using a NodeJS environment (like here) I’ve delevoped a simple PHP class to create a webhooks endpoint in a LAMP (or a similar) environment:

the code is available on GitHub.

Here an example to use the class (put it together with the class script in a https web server folder and configure Alma webhook using the url as endpoint; you can choose both JSON and XML output formats):

$webh = new almaWebhook('Secret'); // or $webh = new almaWebhook() if you place secret in class file directly;
if ($webh->result) {
    //your code (use $webh->res_obj to collect data; if you prefer arrays, use $dataray = (array)$webh->res_obj, $web->result contains result as a string);
    $action = $webh->res_obj->action // event type in Alma    
    $webh->addLog("this is happening") // add info to log
file_put_contents("filelog.txt", $webh->log, FILE_APPEND); // save log to a file

Leave a Reply