As part of (one of) my day jobs, I have had to yet again bash together a set of REST APIs. This is so we can start wiring up some proper micro services AWS style scalable architecture into the monolithic beast that is the current incarnation of the software I’m working on.

Anyway, here are a few gotchas for this if you intend to start using proper REST style HTTP verbs (PUT/PATCH/DELETE), rather than doing everything via GET and POST like most everyone.

No easy way to access variables

If you’re familiar with the standard $_POST mechanism to access passed variables, you’ll be disappointed that PHP doesn’t by default provide a nice way of access these for PUT and PATCH.

So, you’re going to have to extract them yourself. Not overly tricky, but irritating:

So, for example:

Requests not coming through

If you find that your APIs work fine on your local machine but break when deployed, you might want to check your server configuration.

It is quite common for web servers (especially on shared hosts) to block access to HTTP verbs other than most common GET and POST. Modsecurity’s default config definitely blocks these methods.

You should also check that any proxies or load balancers that you have in front of your REST endpoint. These may need some configuration tweaks as well.

Hopefully this will save you some time and frustration!

Just another quick update…

In an ongoing effort to make use of the Known API easier and more flexible, the latest version available in GitHub, or via my unofficial packages, now has built in support for OAuth2.

OAuth2 server functionality is provided by an updated version of my OAuth2 Server code, which I’ve written a bit about before.

Going forward, I’m hoping to build out an easier way for third party clients to be able to connect, paving the way for a possible mobile client.

Anyway, go grab the latest version and have a play!

Just a quick one.

I’ve been playing about with Node.js some more, and very quickly (alarmingly quickly) hacked together a very simple Node library for talking to the Known API.

The main.js has an example where I will post a status update, but obviously other updates are possible.

Have a play!

» Visit the project on Github...