Schibsted and Blocket Hackday mission
Prime directive: make something you learn stuff from. If it can benefit Blocket or Schibsted, that’s good, but it doesn’t have to affect the indigenous population @theoffice. It is desirable to present what you’ve done and your learnings though, but it mustn’t be code.
Mission oAuth: I had been asking around as to how to connect to Blocket’s API, but everyone kept saying it’s messy, so monkey wanted to give it a try 🙂 I mean, how hard can it be right?
WP Plugin: I also wanted to make a WordPress plugin that consumes the API (read only), so I set up this testblog.
One Hackday never enough: The perfect playground would be a hackday, but introducing several new concepts at once can often end up in a mess and many hacknights, so I cheated and prepared the connection the night before and read up on WP plugins. No more cheating here, I promise!
Learnings after the Schibsted #22 hackday in May 2019 were:
- To make a somewhat secure WP plugin for the WP admin to config categories and search words. Usable only in categories where you allow the API key.
- To do the actual authentication is easier with an example. Docs work if you’re alone but friends save time.
- To parse the string I got (which didn’t let itself become a PHP array or object until I finally read up on how to properly cURL it).
- To CSS-ify it all to be responsive with as little code as possible, use Flexbox FTW!
- All of the above in one day… pheew. 400 lines of code with generous spacing.
- There’s a Git repo I started somewhere. Here’s the URL.
Learnings after #23 Sch-hackday in Nov. 2019:
- Once you’ve figured it out, WordPress is really well thought out with it’s plugin system. Many go: “naah, I don’t do PHP, WP etc” but in how many libraries can you cover developing a whole eco system of functions from day one (or actually two or three) without much prior knowledge?
- WordPress documentation is awesome.
- Addendum: once I had the main settings going from the 2:nd Hackday, it wasn’t that hard work to use WordPress shortcode to override the basic query and consume multiple instances of the Blocket API in different categories. This was done aprés L’hackday.
Well, that’s all folks.