JSON Feed Plugin

Hi folks,

In the last days a new type of RSS Feed was announced: https://jsonfeed.org/
I’m a big fan of JSON an decided to add a JSON Feed in my own site and publish the code as a plugin on Github.

My first Kirby plugin. So if you find bugs or have suggestions, please let me know here or open an issue or pull request on Github.

Cheers :v:

1 Like

Additional links:

Mhmm… my feed seems to work (I can see the feed entries when I access the url), but when I subscribe to my feed (via Feedbin), the feed is empty. Is this a error within Feedbin or with your plugin?

Does Feedbin already support the JSON Feed Format? The standard is quite
new and I don’t know which RSS reader already support it.

https://feedbin.com/blog/2017/05/22/feedbin-supports-json-feed/

Yeap, they support JSON since a few days. @texnixe posted the blog post where they announced the support.

Cool. Currently on a boat. Will look into that when I’m home

FWIW, its also supported by NewsBlur

One difference I noticed to your implementation: My “feed_url” is empty. Could that be the cause? And if so, how to fix that?

Update: I just added the feed url directly into the json_feed.php. I know thats probably not correct, but at least “feed_url” is now filled correctly. My JSON feed seems to work in Newsblur right now. But its still not working in Feedbin. So now its more likely an error on Feedbin site (IMHO its a caching issue - they still deliver the corrupt feed, even when I resubscribe to the feed). I currently try to contact them.

@rrrrfischer Thanks for the update. Will update the source on Github so there’s a clear description how the feed_url should be set.

Edit: Updated the README with some documentation about the options you can pass to the method: https://github.com/stefanzweifel/kirby-json-feed#usage

1 Like

@stefanzweifel Yeap, it was a bug within Feedbin - which is now fixed.

During the test, I’ve found another glitch: Feedbin requires the “date_published” entry. Otherwise all entries are displayed with the time Feedbin was catching the feed/article. Currently there is only the “date_modified” key inside the feed. It would be great if you would add the “date_published” key to the feed :slight_smile:

Update: As I recognized, that “date_modified” already contained the publish date (instead of the the last update date), I just changed “date_modified” to “date_published” inside the “json-feed.php”.

So, IMHO there is just a solution needed, for the “date_modified” key (as it currently contains the publish date).

Thanks for the info.
Created an issue and published a new release yesterday.

Now both keys (date_modified and date_published) are in the item list. (But I know that their not the same and should probably be a separate field)

1 Like

Thanks! Is there any way to write the real (last) modified date into the “date_modified” key? Currently it seems that both keys contain the publish date?!

Well, not by default.

The Plugin currently just uses the “date” field (Link
https://github.com/stefanzweifel/kirby-json-feed/blob/master/json-feed.php#L30-L31).
Kirby doesn’t have the concept of “published date” and “modified date” by
default. You could however add a new field called “date_modified” in your
blueprints, set it in your pages and adjust the json-feed plugin.

The plugin code should be simple enough so everyone can add or remove the
fields he or she wants. If the JSON feed would get a lot of traction I
would add all remaining fields. But currently I think thats an overkill.

René Fischer getkirby@discoursemail.com schrieb am Di., 30. Mai 2017 um
14:05 Uhr:

Okay, accepted! IHMO that key is not that necessary (at least for me), as most feed readers track updated feeds / articles themselves. So I live without the “date_modified” key for now :slight_smile:

You could also use $page->modified(). This timestamp is updated when a page is modified via the Panel.

Nice. Didn’t know about that.

Hey @stefanzweifel, kudos for the json plugin! Looks great!

I was just thinking if the counterpart is doable. Would it be possible to READ/PARSE a JSON Feed on Kirby? Do anyone know if a plugin for that exists?

I’ve quickly scrambled the following code together. I reads a Feed, parses the JSON and loops over all items.

    $feed = json_decode(file_get_contents('https://stefanzweifel.io/feed.json'));
    $items = $feed->items;

    foreach ($items as $item) {

        echo $item->title;
        echo $item->content_html;
        echo $item->url;
        echo $item->date_published;

    }

(You could please this in Kirby Controller)

But keep in mind that in a production ready application I would advise to cache the JSON Feed for x amount of time :wink:

Very cool. Thanks for sharing!