Hall.com Chat API PHP Example

I was not able to find any good examples so I made one specific for php and hall.com’s api

I use it to notify the helpdesk lobby of an incoming call on my freePBX 🙂

<?php
function HallAPI($message) {
$data = array(“title” => “Alert”, “message” => $message, “picture” => “http://domain.com/logo.jpg”);
$data_string = json_encode($data);
$result = @file_get_contents(‘https://hall.com/api/1/services/generic/*********APIKEY*******’, null, stream_context_create(array(
‘http’ => array(
‘method’ => ‘POST’,
‘header’ => ‘Content-Type: application/json’ . “\r\n”
. ‘Content-Length: ‘ . strlen($data_string) . “\r\n”,
‘content’ => $data_string,
),
)));
};
HallAPI(“Test”);
?>

 

 

Say Something Nice