added first version which works with Mr.Reader 2.0
This commit is contained in:
10
README.md
10
README.md
@@ -30,6 +30,10 @@ Full Support
|
||||
|
||||
* Reeder - iPhone
|
||||
|
||||
Limited support
|
||||
|
||||
* Mr.Reader - iPad - can currently only load and show items, can **not** read/star items
|
||||
|
||||
## <a name="installation">Installation</a>
|
||||
|
||||
Upload the ```fever``` folder in the ```plugins``` folder of your TinyTinyRSS installation. Enable the plugin in the preferences and set your password for the Fever API.
|
||||
@@ -45,3 +49,9 @@ Licensed under GNU GPL version 2 (<- I think this is okay for this plugin…)
|
||||
v1.0-v1.2 - 2013/5/27 - DigitalDJ version
|
||||
|
||||
* see this [thread](http://tt-rss.org/forum/viewtopic.php?f=22&t=1981) in the TinyTinyRSS Forum
|
||||
|
||||
v1.3 - 2013/6/27
|
||||
|
||||
* fixed several bugs in json output from the plugin
|
||||
* added a small fix for Mr.Reader 2.0 so it can complete loading of all items
|
||||
* added first Mr.Reader compatiblity without marking items read/starred
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
class FeverAPI extends Handler {
|
||||
|
||||
const API_LEVEL = 3;
|
||||
@@ -6,6 +7,10 @@ class FeverAPI extends Handler {
|
||||
const STATUS_OK = 1;
|
||||
const STATUS_ERR = 0;
|
||||
|
||||
// debugging only function with JSON
|
||||
const DEBUG = 0; // enable if you need some debug output in your tinytinyrss root
|
||||
const DEBUG_USER = 1; // your user id you need to debug - look it up in your mysql database
|
||||
|
||||
private $xml;
|
||||
|
||||
// always include api_version, status as 'auth'
|
||||
@@ -17,9 +22,9 @@ class FeverAPI extends Handler {
|
||||
|
||||
if ($status == self::STATUS_OK)
|
||||
{
|
||||
$arr["last_refreshed_on_time"] = $this->lastRefreshedOnTime()."";
|
||||
if (!empty($reply) && is_array($reply))
|
||||
$arr = array_merge($arr, $reply);
|
||||
$arr["last_refreshed_on_time"] = $this->lastRefreshedOnTime();
|
||||
}
|
||||
|
||||
if ($this->xml)
|
||||
@@ -29,6 +34,10 @@ class FeverAPI extends Handler {
|
||||
else
|
||||
{
|
||||
print json_encode($arr);
|
||||
if (DEBUG==1) {
|
||||
// debug output
|
||||
file_put_contents('./debug_fever.txt','answer : '.json_encode($arr)."\n",FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +126,10 @@ class FeverAPI extends Handler {
|
||||
{
|
||||
$_SESSION["uid"] = $this->dbh->fetch_result($result, 0, "owner_uid");
|
||||
}
|
||||
|
||||
if (DEBUG==1) {
|
||||
$_SESSION["uid"] = DEBUG_USER; // always authenticate and set debug user
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +149,7 @@ class FeverAPI extends Handler {
|
||||
foreach ($groupsToGroups[$index] as $item)
|
||||
{
|
||||
$id = substr($item, strpos($item, "-") + 1);
|
||||
array_push($groups, array("id" => $id, "title" => $groupsToTitle[$id]));
|
||||
array_push($groups, array("id" => intval($id), "title" => $groupsToTitle[$id]));
|
||||
if (isset($groupsToGroups[$id]))
|
||||
$this->flattenGroups($groupsToGroups, $groups, $groupsToTitle, $id);
|
||||
}
|
||||
@@ -201,8 +214,8 @@ class FeverAPI extends Handler {
|
||||
|
||||
while ($line = $this->dbh->fetch_assoc($result))
|
||||
{
|
||||
array_push($feeds, array("id" => $line["id"],
|
||||
"favicon_id" => $line["id"],
|
||||
array_push($feeds, array("id" => intval($line["id"]),
|
||||
"favicon_id" => intval($line["id"]),
|
||||
"title" => $line["title"],
|
||||
"url" => $line["feed_url"],
|
||||
"site_url" => $line["site_url"],
|
||||
@@ -228,7 +241,7 @@ class FeverAPI extends Handler {
|
||||
$filename = "feed-icons/" . $line["id"] . ".ico";
|
||||
if (file_exists($filename))
|
||||
{
|
||||
array_push($favicons, array("id" => $line["id"],
|
||||
array_push($favicons, array("id" => intval($line["id"]),
|
||||
"data" => image_type_to_mime_type(exif_imagetype($filename)) . ";base64," . base64_encode(file_get_contents($filename))
|
||||
));
|
||||
}
|
||||
@@ -360,7 +373,8 @@ class FeverAPI extends Handler {
|
||||
if ($since_id)
|
||||
{
|
||||
if (!empty($where)) $where .= " AND ";
|
||||
$where .= "id > " . db_escape_string($since_id) . " ";
|
||||
//$where .= "id > " . db_escape_string($since_id) . " ";
|
||||
$where .= "id > " . db_escape_string($since_id*1000) . " "; // NASTY hack for Mr. Reader 2.0 on iOS and TinyTiny RSS Fever
|
||||
}
|
||||
else if (empty($where))
|
||||
{
|
||||
@@ -374,21 +388,21 @@ class FeverAPI extends Handler {
|
||||
$where .= " LIMIT " . $item_limit;
|
||||
|
||||
// id, feed_id, title, author, html, url, is_saved, is_read, created_on_time
|
||||
$result = $this->dbh->query("SELECT ref_id, feed_id, title, link, content, id, marked, unread, author, date_entered
|
||||
$result = $this->dbh->query("SELECT ref_id, feed_id, title, link, content, id, marked, unread, author, updated
|
||||
FROM ttrss_entries, ttrss_user_entries
|
||||
WHERE " . $where);
|
||||
|
||||
while ($line = $this->dbh->fetch_assoc($result))
|
||||
{
|
||||
array_push($items, array("id" => $line["id"],
|
||||
"feed_id" => $line["feed_id"],
|
||||
array_push($items, array("id" => intval($line["id"]),
|
||||
"feed_id" => intval($line["feed_id"]),
|
||||
"title" => $line["title"],
|
||||
"author" => $line["author"],
|
||||
"html" => $line["content"],
|
||||
"url" => $line["link"],
|
||||
"is_saved" => (sql_bool_to_bool($line["marked"]) ? 1 : 0),
|
||||
"is_read" => ( (!sql_bool_to_bool($line["unread"])) ? 1 : 0),
|
||||
"created_on_time" => strtotime($line["date_entered"])
|
||||
"created_on_time" => strtotime($line["updated"])
|
||||
));
|
||||
}
|
||||
|
||||
@@ -451,7 +465,7 @@ class FeverAPI extends Handler {
|
||||
$unreadItemIdsCSV = "";
|
||||
$result = $this->dbh->query("SELECT ref_id, unread
|
||||
FROM ttrss_user_entries
|
||||
WHERE owner_uid = '" . db_escape_string($_SESSION["uid"]) . "'");
|
||||
WHERE owner_uid = '" . db_escape_string($_SESSION["uid"]) . "'"); // ORDER BY red_id DESC
|
||||
|
||||
while ($line = $this->dbh->fetch_assoc($result))
|
||||
{
|
||||
@@ -676,6 +690,10 @@ class FeverAPI extends Handler {
|
||||
// validate the api_key, user preferences
|
||||
function before($method) {
|
||||
if (parent::before($method)) {
|
||||
if (DEBUG==1) {
|
||||
// add request to debug log
|
||||
file_put_contents('./debug_fever.txt','parameter: '.json_encode($_REQUEST)."\n",FILE_APPEND);
|
||||
}
|
||||
|
||||
// set the user from the db
|
||||
$this->setUser();
|
||||
|
||||
Reference in New Issue
Block a user