Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Wallboard JSON feed

After using OS Ticket for last few years I wanted  to added some functionality that I could have basic SQL queries to do, but I decided to investigate the source and come with my own flavour of a Wallboard JSON feed. I use feed on an intranet server to keep up to date with the open ticket numbers.

Please see GPL code below.. which I know could be written better, but I had only 2 hrs or so to review and build.

I have stored this file in the api folder and named it wallboard.php


<?php

// Disable sessions for the API. API should be considered stateless and
// shouldn't chew up database records to store sessions
if (!defined('DISABLE_SESSION'))
    define('DISABLE_SESSION', true);
// Init OS Ticket System
file_exists('../main.inc.php') or die('System Error');
require_once('../main.inc.php');
//Validate API Token
require_once(INCLUDE_DIR.'class.api.php');
$id = "";
 if (isset($_POST['API_KEY']) && isset($_SERVER['REMOTE_ADDR']))
 $id = API::getIdByKey($_POST['API_KEY'], $_SERVER['REMOTE_ADDR']);

if (!$id)
{
 header("HTTP/1.1 401 Unauthorized");
 echo "Valid API key required";
 return;
}
//Create SQL
$sql = "SELECT number, updated FROM " . TICKET_TABLE . " WHERE " . TICKET_TABLE . ".status_id in (1,2)
AND " . TICKET_TABLE . ".isanswered = 0";
//Execute SQL
 $res = db_query($sql,true);
 
 //Create temporary list and load db result
$result = [];
while ($data = db_fetch_array($res)) { $result[] = $data;}
// Ouput JSON encode data
echo json_encode($result);
// Free result set
db_free_result($res);

Comments

  • edited November 2016
    This does not appear to be a suggestion or feedback.
    Moving to mods and customizations.

    You might want to post a screen shot of what your mod does.  
    You also might want to post what version of osTicket you wrote it for.
  • The wallboard script has been built for v1.10

    A json array of ticket numbers and last update time is returned when the user posts a valid api token
Sign In or Register to comment.