# JSON Feed Plugin

**URL:** <https://forum.getkirby.com/t/json-feed-plugin/7578>\
**Category:** Plugins\
**Created:** [May 24, 2017, 9:32pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578 "2017-05-24T21:32:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 24, 2017, 9:32pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/1 "2017-05-24T21:32:23Z")

</div>

Hi folks,

In the last days a new type of RSS Feed was announced: [https://jsonfeed.org/](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.

- Github: [https://github.com/stefanzweifel/kirby-json-feed](https://github.com/stefanzweifel/kirby-json-feed)

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 ✌️

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 24, 2017, 9:33pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/2 "2017-05-24T21:33:03Z")

</div>

Additional links:

- [Live Implementation](https://github.com/stefanzweifel/stefanzweifel.io/blob/master/dist/site/templates/json-feed.php)
- Live URL: [http://stefanzweifel.io/feed.json](http://stefanzweifel.io/feed.json)

---

<div class="post-metadata">

**Author:** ![rrrrfischer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rrrrfischer](https://forum.getkirby.com/u/rrrrfischer)\
**Post date:** [May 26, 2017, 7:56am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/3 "2017-05-26T07:56:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 26, 2017, 8:09am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/4 "2017-05-26T08:09:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 26, 2017, 8:25am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/5 "2017-05-26T08:25:40Z")

</div>

[https://feedbin.com/blog/2017/05/22/feedbin-supports-json-feed/](https://feedbin.com/blog/2017/05/22/feedbin-supports-json-feed/)

---

<div class="post-metadata">

**Author:** ![rrrrfischer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rrrrfischer](https://forum.getkirby.com/u/rrrrfischer)\
**Post date:** [May 26, 2017, 8:30am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/6 "2017-05-26T08:30:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 26, 2017, 8:55am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/7 "2017-05-26T08:55:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![omz13](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/omz13/32/4105_2.png) [@omz13](https://forum.getkirby.com/u/omz13)\
**Post date:** [May 26, 2017, 10:27am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/8 "2017-05-26T10:27:05Z")

</div>

FWIW, its also supported by [NewsBlur](http://blog.newsblur.com/post/160982162270/newsblur-now-supports-the-new-json-feed-spec)

---

<div class="post-metadata">

**Author:** ![rrrrfischer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rrrrfischer](https://forum.getkirby.com/u/rrrrfischer)\
**Post date:** [May 26, 2017, 11:22am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/9 "2017-05-26T11:22:10Z")

</div>

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

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/2/233ed0b590616e0230dd3b1c9a8e17aef3485f84.png)

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.

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/e/e90a9b3b61f7ac240ac3b6b2eddbd52c8a148a5c.png)

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 26, 2017, 3:02pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/10 "2017-05-26T15:02:16Z")

</div>

@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](https://github.com/stefanzweifel/kirby-json-feed#usage)

---

<div class="post-metadata">

**Author:** ![rrrrfischer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rrrrfischer](https://forum.getkirby.com/u/rrrrfischer)\
**Post date:** [May 28, 2017, 11:10pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/11 "2017-05-28T23:10:36Z")

</div>

@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 🙂

**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).

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 30, 2017, 11:30am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/12 "2017-05-30T11:30:12Z")

</div>

Thanks for the info.  
Created an [issue](https://github.com/stefanzweifel/kirby-json-feed/issues/3) and published a [new release](https://github.com/stefanzweifel/kirby-json-feed/releases/tag/v1.2.0) 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)

---

<div class="post-metadata">

**Author:** ![rrrrfischer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rrrrfischer](https://forum.getkirby.com/u/rrrrfischer)\
**Post date:** [May 30, 2017, 11:55am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/13 "2017-05-30T11:55:04Z")

</div>

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?!

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 30, 2017, 12:21pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/14 "2017-05-30T12:21:25Z")

</div>

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](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](mailto:getkirby@discoursemail.com) schrieb am Di., 30. Mai 2017 um  
14:05 Uhr:

---

<div class="post-metadata">

**Author:** ![rrrrfischer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rrrrfischer](https://forum.getkirby.com/u/rrrrfischer)\
**Post date:** [May 30, 2017, 12:36pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/15 "2017-05-30T12:36:11Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 30, 2017, 12:38pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/16 "2017-05-30T12:38:05Z")

</div>

You could also use [`$page->modified()`](https://getkirby.com/docs/cheatsheet/page/modified). This timestamp is updated when a page is modified via the Panel.

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [May 30, 2017, 1:00pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/17 "2017-05-30T13:00:29Z")

</div>

Nice. Didn’t know about that.

---

<div class="post-metadata">

**Author:** ![paulschwarz](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@paulschwarz](https://forum.getkirby.com/u/paulschwarz)\
**Post date:** [June 2, 2017, 12:30pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/18 "2017-06-02T12:30:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stefanzweifel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/stefanzweifel/32/5193_2.png) [@stefanzweifel](https://forum.getkirby.com/u/stefanzweifel)\
**Post date:** [June 2, 2017, 8:04pm UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/19 "2017-06-02T20:04:57Z")

</div>

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

```php
    $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 😉

---

<div class="post-metadata">

**Author:** ![paulschwarz](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@paulschwarz](https://forum.getkirby.com/u/paulschwarz)\
**Post date:** [June 7, 2017, 7:02am UTC](https://forum.getkirby.com/t/json-feed-plugin/7578/20 "2017-06-07T07:02:59Z")

</div>

Very cool. Thanks for sharing!

[Next page](https://forum.getkirby.com/t/json-feed-plugin/7578.md?page=2)
