亚历山德罗·米诺奇里 / wordpress-rest-api-client
本包最新版本(v1.3.4)没有提供许可证信息。
v1.3.4
2019-07-25 10:16 UTC
Requires
- php: >= 5.6, <= 8.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^6.2
- peridot-php/leo: ^1.5
- peridot-php/peridot: ^1.18
- peridot-php/peridot-prophecy-plugin: ^1.1
- squizlabs/php_codesniffer: ^2.7
Suggests
- guzzlehttp/guzzle: ^6.2
README
WordPress REST API 的 PHP 客户端
当您需要从其他 PHP 项目中调用 WordPress REST API 时,出于某种原因。
安装
此库可以通过 Composer 安装。
composer require alessandrominoccheri/wordpress-rest-api-client
库运行需要 Http 库。库支持 Guzzle,但您可以使用任何您选择的 Http 库,只要您为该库编写一个适配器。
安装 Guzzle
composer require guzzlehttp/guzzle
用法
示例
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(2); print_r($user);
测试
composer install vendor/bin/peridot