Yesterday, WP API project lead Ryan McCue announced three special updates for WP REST API users, which includes new tools and a massive OAuth update.
Discovery Library For PHP
Something that is so exciting about the REST API is discoverable, which means that you can rename the API base or give API access to someone else. These features will make things smoother, but they aren’t necessarily easy to set up. At least, that was before the PHP Discovery Library was included.
“To simplify this, we now have a discovery library for PHP 5.3+.
To use it, add wp-api/discovery to your Composer requirements manually or run composer require wp-api/discovery in your project directory,” McCue explains in the blog post.
Then, use WordPress\Discovery\discover() to find the API for any given URL. A public version is in the works, which would allow for users to use it without installing it.
New OAuth Server
The OAuth Server hasn’t kept up to standards until now.
“For a long time, our OAuth server plugin has languished and fallen behind as we push forward with the API. No longer is this the case!” McCue explained.
All you have to do is update to the latest master. Some of the changes include fall admin UI, ability to delete applications and regenerate secrets, overhauled internals and callback validation process.
Another big change is documentation, which hasn’t been easy in the past. Luckily this is now fixed, and you can read all about it on GitHub.
Demo API Client
If this wasn’t good enough, you can now download the Demo API Client in PHP to try all of these changes out. It works by using the discovery library to find your site, then connects with OAuth.
“You can run this locally using PHP’s built-in server, and we’re working on getting a version set up on wp-api.org too,” McCue said.
The discovery library and API client are open source and MIT licensed so you can use them however you wish. These additions to the WP REST API make us even more excited for WordPress 4.4, slated to ship today.
No Comments