Subscription List with the Feedly API

A lot of websites out there used to have a “blog roll” which is a list of blogs the writer likes and/or reads regularly. I wanted to create something similar based on my blog reading but I wanted it to be updated on it’s own without my needing to go in and update it manually whenever I found something new. So what was the solution?

I decided to my subscription list with the Feedly API and display that as my blog roll!

In this post I will explain how I integrated the Feedly API into my WordPress site to display my current subscription list.

Note you can see the final implementation here.

Now bear in mind this was my first experience with PHP (the language WordPress is written in) and my first experience with an API so it’s be no means perfect. In fact please feel free to leave a comment or email me to let me know how I might be able to improve things. Anyway, let’s see how I did it!

First off you can see the source code here if you’d like to follow along.

Get the Subscriptions From the Feedly API

To start off with I need to make the call to the Feedly API to retrieve a list of the feeds I am subscribed to. To do this I used the PHP curl function.

I set the URL to the Feedly API subscriptions service.

I then set the OAuth header with my dev token which I obtained from Feedly. This dev token gives me access to my Feedly profile only and it has a limited number of polls each day. It’s basically supposed to be used for testing/dev work but it works well in our case here.

Then we set the cURL options, execute the call and capture the output.

Lastly we need to get the response into a usable format. The Feedly API responds with a JSON string s we use json_decode to put the response into a PHP array.

Setup Our Classes and Variables

The response we initially get from the Feedly API is just an array of subscriptions but I wanted to display them in groups based on the categories I’d set within Feedly. In order to do this I needed to transform the response array into a more usable format. I did this by creating a couple of classes as shown:

I found that in order to properly reference the various levels within the PHP array which contained the response I needed to use variables for the item names. We set these up now as well as initialise our main categories variable which will contain the newly transformed data.

Transform Data into Our New Classes

Now we loop through all our subscriptions which we obtained in the Feedly response and place them into our new class variable as an array of categories.

One ‘gotcha’ here I found is that I couldn’t just add the items to the arrays inline. I wanted to try something like:

But it didn’t like that so instead I had to initialise the data into temp variables first and then push them into the array.

Print Output

Then finally we go ahead and echo out our formatted results:

Running PHP in WordPress

One last thing I had to do in order to be able to embed this into a WordPress page was to use a plugin called PHP Code for Posts. This lets you use short codes to insert PHP code into your WordPress posts, pages, whatever. A nice simple plugin that does exactly what it says it will.


In the end this was a fun little adventure into PHP and APIs.

I learnt a bit about PHP syntax and some of the differences between languages I’m used to like C#.

I also learnt about interacting with a simple API, making HTTP GET requests and handling JSON responses.

Plus I also made something useful at least to me! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *