cjrasmussen / wordpress-api
Simple helper for interacting with the WordPress REST API
1.0.3
2024-09-11 23:02 UTC
Requires
- php: >=7.4.0
- ext-curl: *
- ext-json: *
README
Simple class for making authenticated requests to the WordPress REST API. Not affiliated with WordPress. Currently only supports basic auth.
Usage
use cjrasmussen\WordpressApi\WordpressApi; $wpApi = new WordpressApi($url); // SET BASIC AUTH TOKEN $wpApi->setAuthBasicToken('jfheriberwoifnoewigah'); // GET THE DATA ABOUT A SPECIFIED POST $data = $wpApi->request('GET', "v2/posts/{$post_id}"); // SET BASIC AUTH TOKEN VIA USERNAME AND PASSWORD $wpApi->setAuthUserPass('someuser', '1insecurepassword'); // DELETE A SPECIFIED MEDIA ITEM $ipb->request('DELETE', "/v2/media/{$media_id}");
Installation
Simply add a dependency on cjrasmussen/wordpress-api to your composer.json file if you use Composer to manage the dependencies of your project:
composer require cjrasmussen/wordpress-api
Although it's recommended to use Composer, you can actually include the file(s) any way you want.
License
WordpressApi is MIT licensed.