weew / http-client
可扩展的http客户端。
v1.8.0
2017-02-22 17:42 UTC
Requires
- weew/curl-wrapper: ^1.1
- weew/http: ^1.11
- weew/url: ^v2.2.0
Requires (Dev)
- phpunit/phpunit: ^4.7
- satooshi/php-coveralls: ^0.6.1
- weew/http-blueprint: ^2.1.0
README
目录
安装
composer require weew/http-client
简介
请查看上面引用的HTTP层项目,因为它做了大部分工作,并为底层的HttpRequest和HttpResponse对象提供了文档。
此库使用CURL传输和接收数据。
用法
以下是如何使用它的一个非常基本的示例。
$client = new HttpClient(); $request = new HttpRequest( HttpRequestMethod::GET, new Url('http://google.com') ); // returns an HttpResponse $response = $client->send($request); // send response directly to the browser (act like a proxy) $response->send();
JsonClient
有一个稍微不同的HttpClient实现,旨在在您确定总是会收到json响应时使用。JsonClient
将自动将HttpResponse
转换为JsonResponse
。
$client = new JsonClient();