matricali / http-client
libcurl的包装器,实现了PSR-7 HTTP消息接口。
1.0.0-alpha3
2018-07-20 13:40 UTC
Requires
- php: >=5.4.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~1.0
- squizlabs/php_codesniffer: ~1.5
This package is auto-updated.
Last update: 2024-09-11 14:48:31 UTC
README
PSR-7 HTTP客户端(cURL)
注意,这不是HTTP协议的实现。它仅仅是libcurl的包装器,实现了PSR-7 HTTP消息接口。
要求
- PHP 5.4或更高版本
- cURL扩展
安装
composer require matricali/http-client
使用
发送GET请求
use Matricali\Http\Client;
$client = new Client();
$response = $client->get('http://www.example.com/');
echo $response->getBody();
发送POST请求
use Matricali\Http\Client;
$client = new Client();
$payload = '{"name": "John Doe"}';
$response = $client->post('http://www.example.com/', $payload);
echo $response->getBody();
贡献
欢迎贡献、问题报告、拉取请求。请参阅CONTRIBUTING.md
许可证
php-http-client遵循MIT许可证。