Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> A Wordpress REST API client for PHP

[![Travis](https://img.shields.io/travis/varsitynewsnetwork/wordpress-rest-api-client.svg?maxAge=2592000?style=flat-square)](https://travis-ci.org/varsitynewsnetwork/wordpress-rest-api-client)

For when you need to make [Wordpress REST API calls](http://v2.wp-api.org/) from
some other PHP project, for some reason.

Expand All @@ -16,10 +18,16 @@ composer require vnn/wordpress-rest-api-client
Example:

```php
$client = new WpClient($url);
$client->setCredentials(new WpBasicCredentials('username', 'password'));
use Vnn\WpApiClient\Auth\WpBasicAuth;
use Vnn\WpApiClient\Http\GuzzleAdapter;
use Vnn\WpApiClient\WpClient;

require 'vendor/autoload.php';

$client = new WpClient(new GuzzleAdapter(new GuzzleHttp\Client()), 'http://yourwordpress.com');
$client->setCredentials(new WpBasicAuth('user', 'securepassword'));

$user = $client->users()->get(15);
$user = $client->users()->get(2);

echo $user['username'];
print_r($user);
```
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
"Vnn\\WpApiClient\\": "src/"
}
},
"require": {
"php": ">= 7.0, <= 8.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"peridot-php/peridot": "^1.18",
"peridot-php/leo": "^1.5",
"squizlabs/php_codesniffer": "^2.7"
"squizlabs/php_codesniffer": "^2.7",
"guzzlehttp/guzzle": "^6.2",
"peridot-php/peridot-prophecy-plugin": "^1.1"
},
"suggest": {
"guzzlehttp/guzzle": "^6.2"
}
}
Loading