Skip to content

Commit 4b747e8

Browse files
Merge pull request #1 from mrkrstphr/implementation
Wordpress API client implementation
2 parents 475c4ab + cc55ab2 commit 4b747e8

24 files changed

+1393
-9
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
> A Wordpress REST API client for PHP
44
5+
[![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)
6+
57
For when you need to make [Wordpress REST API calls](http://v2.wp-api.org/) from
68
some other PHP project, for some reason.
79

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

1820
```php
19-
$client = new WpClient($url);
20-
$client->setCredentials(new WpBasicCredentials('username', 'password'));
21+
use Vnn\WpApiClient\Auth\WpBasicAuth;
22+
use Vnn\WpApiClient\Http\GuzzleAdapter;
23+
use Vnn\WpApiClient\WpClient;
24+
25+
require 'vendor/autoload.php';
26+
27+
$client = new WpClient(new GuzzleAdapter(new GuzzleHttp\Client()), 'http://yourwordpress.com');
28+
$client->setCredentials(new WpBasicAuth('user', 'securepassword'));
2129

22-
$user = $client->users()->get(15);
30+
$user = $client->users()->get(2);
2331

24-
echo $user['username'];
32+
print_r($user);
2533
```

composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@
55
"Vnn\\WpApiClient\\": "src/"
66
}
77
},
8+
"require": {
9+
"php": ">= 7.0, <= 8.0",
10+
"psr/http-message": "^1.0"
11+
},
812
"require-dev": {
913
"peridot-php/peridot": "^1.18",
1014
"peridot-php/leo": "^1.5",
11-
"squizlabs/php_codesniffer": "^2.7"
15+
"squizlabs/php_codesniffer": "^2.7",
16+
"guzzlehttp/guzzle": "^6.2",
17+
"peridot-php/peridot-prophecy-plugin": "^1.1"
18+
},
19+
"suggest": {
20+
"guzzlehttp/guzzle": "^6.2"
1221
}
1322
}

0 commit comments

Comments
 (0)