toanld / wordpress-rest-api-client
此包的最新版本(dev-master)没有可用的许可信息。
dev-master
2023-02-07 07:20 UTC
Requires
- php: ^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 auto-updated.
Last update: 2024-09-07 10:34:43 UTC
README
PHP的Wordpress REST API客户端
当您需要从其他PHP项目进行Wordpress REST API调用时,可以使用此客户端。
安装
此库可以通过Composer安装
composer require toanld/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