How to fetch Libsyn download counts in Wordpress

Cory Pratt

I recently had an interesting task of dynamically fetching Libsyn download counts and displaying them in Wordpress. Naturally I begin searching for some sort of API and much to my surprise, Libsyn provides nothing of the sort. More Googling landed me on a handy PHP script that Marco Arment posted on Github for pulling numbers into Panic's Status Board. Unfortunately his script was a little outdated but it was a great launching point to begin porting over to a Wordpress plugin.

At a high level, I needed the plugin to log into Libsyn and parse a CSV, then store the numbers in the database where they could be retrieved quick. As opposed to using cURL as Marco did, I opted to use Wordpress' wp_remote_post to login and grab the returned CSV.

Using some of Marco's code, the CSV is parsed and stored as transients in the Wordpress database

I should build some shortcodes in, but at this point displaying the counts is as easy as echoing the transient in a template file using something like

echo get_transient( '_libsyn_count' );

You can find the simple plugin at my Libsyn Download Count repository. Please fork and edit as you please!