matricali/http-client

libcurl的包装器,实现了PSR-7 HTTP消息接口。

1.0.0-alpha3 2018-07-20 13:40 UTC

This package is auto-updated.

Last update: 2024-09-11 14:48:31 UTC


README

Latest stable release Build Status Coverage Status MIT licensed GitHub contributors

PSR-7 HTTP客户端(cURL)

注意,这不是HTTP协议的实现。它仅仅是libcurl的包装器,实现了PSR-7 HTTP消息接口。

要求

安装

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许可证