Tiny Tiny RSS: Community

Simple API to update feeds via HTML get


#1

I’m not sure if this is really needed. But for those who

  • Don’t have access to terminal to add systemd and crontab
  • Want to manually update feeds

I write a simple api to allow manually update feeds via visiting URL:

https://yourdomain/my_update.php?user=yourusername&password=yourpassword
// save as my_update.php in the root directory of your tt-rss installation
// replace YOUR-TTRSS-ROOT-DIRECTORY correctly
<?php

require_once "config.php";
set_include_path(dirname(__FILE__) . PATH_SEPARATOR .
  dirname(__FILE__) . "/include" . PATH_SEPARATOR .
  get_include_path());

require_once "autoload.php";
if (!init_plugins()) return;

require_once('functions.php');
if ($_GET["user"] && $_GET["password"]){
  if (authenticate_user($_GET["user"], $_GET["password"])) {
    header('Content-Type: text/plain');
    $username=$_GET["user"];
    echo("Welcome $username \n\n");
    exec('/usr/bin/php ' . dirname(__FILE__) . '/update.php --force-update --feeds', $output, $return_code );
    if($return_code == 0) {
      foreach ($output as $key => $val){
        echo "$val \n";
      }
    }
  } else {
    header($_SERVER['SERVER_PROTOCOL'] .' 404 Not Found');
    exit(1);
  }
} else {
  header($_SERVER['SERVER_PROTOCOL'] .' 404 Not Found');
  exit(1);
}
?>

If you are an IOS>11 user, you can also create a shortcut via app “Shorcuts” (Apple official app)

@fox I wonder if I get get permission to create a fork? :slight_smile: Thank you!


#2

Thanks for sharing.

In case you’re not aware, there is simple update mode, which should basically do the same thing without all the fuss. But what kind of hosting doesn’t let you at the very least run a cron job?


#3

Wow! The reply is so fast! :sunglasses: Thanks for the whole team behind tt-rss.

I know there exists such function and, actually I host my tt-rss on a VPS so I have full control of all the stuff and either cron or systemd is not a problem.

But there exists someone hosting it on shared servers with only access to ftp and phpmyadmin. I personally also want to update feeds manually sometime by simply clicking a button on my phone.

It’s not necessary to have this at all, but just in case someone needs.


#4

Makes sense.

You could wrap this as a system plugin. Then you could skip the whole authentication part and even add UI menu items or buttons to trigger it.

e: Yes, I know it’s more code and work… :smirk:


#5

why? do you want this added to upstream? the only reason for forks is sending pull requests, otherwise host your own code yourself.


#6

Is there something wrong with /public.php?op=globalUpdateFeeds ? My lame hosting provider only allows me to run a cron job once a day so I’ve been successfully using this for a long time.


#7

no, there’s nothing wrong with it (other than the obvious, i.e. you should use a better update method if you can), but what if you want to put some additional ugly php code on your server? well, op has you covered

expecting password in a http get variable is my favorite part, personally