1. Go to this page and download the library: Download angelxmoreno/wprestclient 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/ */
angelxmoreno / wprestclient example snippets
use WPRestClient\Core\ApiClient;
$client = new ApiClient('https://example.com');
use WPRestClient\Repository\PostsRepositor;
PostsRepository::setApiClient($client);
$posts = PostsRepository::fetch();
foreach ($posts as $post) {
echo $post->getTitle();
}
use WPRestClient\Repository\PagesRepository;
use WPRestClient\Core\RepositoryRegistry;
use WPRestClient\Entity\PageEntity;
$registry = new RepositoryRegistry($client);
$page = new PageEntity(['title' => 'A New Page']);
$registry->pages()->create($page);
use WPRestClient\Repository\PagesRepository;
use WPRestClient\Core\RepositoryRegistry;
use WPRestClient\Entity\PageEntity;
$registry = new RepositoryRegistry($client);
$post = $registry->posts()->get(123);
$registry->posts()->delete($post);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.