From 7fc2945bacc86fb54b7c40291d2484098dda47a1 Mon Sep 17 00:00:00 2001 From: louise Date: Wed, 1 Jul 2009 09:45:12 +0000 Subject: Basic json interface for getting lists of problems --- web/json.cgi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 web/json.cgi (limited to 'web/json.cgi') diff --git a/web/json.cgi b/web/json.cgi new file mode 100755 index 000000000..91f2676a7 --- /dev/null +++ b/web/json.cgi @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w -I../perllib + +# json.cgi: +# A small JSON API for FixMyStreet +# +# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. +# Email: louise@mysociety.org. WWW: http://www.mysociety.org +# +# $Id: json.cgi,v 1.1 2009-07-01 09:45:12 louise Exp $ + +use strict; +use Error qw(:try); +use JSON; +use Standard; + +sub main { + my $q = shift; + my $problems; + my $type = $q->param('type') || ''; + my $start_date = $q->param('start_date') || ''; + my $end_date = $q->param('end_date') || ''; + print $q->header( -type => 'text/html; charset=utf-8' ); + if ($type eq 'new_problems'){ + $problems = Problems::created_in_interval($start_date, $end_date); + } elsif ($type eq 'fixed_problems') { + $problems = Problems::fixed_in_interval($start_date, $end_date); + } + my $out = JSON::to_json($problems); + print $out; +} + + +Page::do_fastcgi(\&main); + -- cgit v1.2.3