PHP code example of cjrasmussen / wordpress-api

1. Go to this page and download the library: Download cjrasmussen/wordpress-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cjrasmussen / wordpress-api example snippets


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}");