One of the things I love about WordPress is all the tools it gives you. Some of these are well known and much-used, like the options and meta APIs. Some are under-utilized, even though they provide great functionality which could make our lives so much easier. Today I’ll be looking at one of these, the HTTP API. The HTTP API consists of a bunch of functions that will help you make HTTP calls a lot more easily. No need to fiddle around with file_get_contents or cURL anymore, just a single unified interface. This is awesome for interacting with third party APIs, especially REST-full ones like Twitter, Facebook, Mailchimp, and others. The Basics Of HTTP We’ve all seen HTTP in action before. In fact, if this is your first time on the web ever and this is the first thing you are reading, you have already seen HTTP working its magic. HTTP is a network protocol used to deliver all files and data (resources) across the Interwebs. There are basically two parts the the equation: the HTTP request and the HTTP response, or transaction. Both the request and the response are very similar in structure, they both have four parts: An initial line Zero or more header lines A blank line An optional body
Share This