malanciault / wordpress-rest-api-client
1.1.5
2020-01-14 16:02 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
This package is not auto-updated.
Last update: 2024-09-18 14:58:57 UTC
README
PHP的WordPress REST API客户端
当你需要从其他PHP项目,由于某种原因,进行WordPress REST API调用时。
安装
此库可以使用Composer进行安装。
composer require vnn/wordpress-rest-api-client
此库运行需要Http库。库支持Guzzle,但你可以使用你选择的任何Http库,只要为该库编写一个适配器。
安装Guzzle
composer require guzzlehttp/guzzle
使用方法
示例
use Malanciault\WpApiClient\Auth\WpBasicAuth; use Malanciault\WpApiClient\Http\GuzzleAdapter; use Malanciault\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