PHP code example of nunocodex / wpapi

1. Go to this page and download the library: Download nunocodex/wpapi 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/ */

    

nunocodex / wpapi example snippets


// GuzzleHttp options
$wpapiClientOptions = [
    'base_uri' => 'http://example.com/',
    'verify' => false,
    'auth' => [ 'user', 'pass' ]
];

// It's a GuzzleHttp extended class so you can bind
// the client with WpApiClientInterface for no change
// anything in this code.
$wpapiClient = new WpApiClient($wpapiClientOptions);

// WpApi object
$wpapi = new WpApi($wpapiClient);

$posts = $wpapi->posts()->embed()->filter([ 'order' => 'asc' ])->pagination(10)->get();