|
From: <ma...@us...> - 2011-10-22 20:16:52
|
Revision: 465
http://openautomation.svn.sourceforge.net/openautomation/?rev=465&view=rev
Author: mayerch
Date: 2011-10-22 20:16:45 +0000 (Sat, 22 Oct 2011)
Log Message:
-----------
Added inital JSON output when the URI parameter "j" is set
Modified Paths:
--------------
tools/rsslog/rsslog.php
Modified: tools/rsslog/rsslog.php
===================================================================
--- tools/rsslog/rsslog.php 2011-10-22 19:10:59 UTC (rev 464)
+++ tools/rsslog/rsslog.php 2011-10-22 20:16:45 UTC (rev 465)
@@ -18,6 +18,8 @@
// 4. Remove old content:
// URL parameter "r": the timestamp (seconds since 1970) of the oldest log
// line to keep
+// 5. Get content as JSON:
+// URL parameter "j"
// create database connection
$db = sqlite_open('rsslog.db', 0666, $error);
@@ -60,6 +62,41 @@
{
$timestamp = $_GET['r'] ? $_GET['r'] : '';
delete( $db, $timestamp );
+} else if( isset($_GET['j']) )
+{
+ ?>
+{
+ "responseData" : {
+ "feed" : {
+ "feedUrl": "<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?>",
+ "title": "RSS supplied logs",
+ "link": "<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?>",
+ "author": "",
+ "description": "RSS supplied logs",
+ "type": "rss20",
+ "entries": [
+<?php
+ $result = retrieve( $db, $log_filter );
+ $first = true;
+ while( sqlite_has_more($result) )
+ {
+ $row = sqlite_fetch_array($result, SQLITE_ASSOC );
+ if( !$first ) echo ",\n";
+ echo '{';
+ echo '"title": "' . $row['content'] . '",';
+ echo '"content": "' . $row['content'] . '",';
+ echo '"publishedDate": "' . date( DATE_RFC822, $row['t'] ) . '"';
+ echo '}';
+ $first = false;
+ }
+?>
+ ]
+ }
+ },
+ "responseDetails" : null,
+ "responseStatus" : 200
+}
+ <?php
} else {
// send logs
$log_filter = $_GET['f'] ? $_GET['f'] : '';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|