vpn / wordpress-rest-api-client
此包最新版本(1.3.0)没有可用的许可证信息。
1.3.0
2020-06-16 19:00 UTC
Requires
- php: ^7.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 auto-updated.
Last update: 2024-09-20 00:35:48 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 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/phpunit