perf/http-client
最新稳定版本:2.0.0
Composer 安装命令:
composer require perf/http-client
包简介
Allows to execute HTTP queries.
README 文档
README
Simple HTTP client using cURL internally.
Installation & Requirements
There are no dependencies on other libraries.
Install with Composer:
composer require perf/http-client
Usage
Simple GET request
<?php use perf\HttpClient\HttpClient; $httpClient = HttpClient::createDefault(); $request = $httpClient->createRequest(); $request ->methodGet() ->setUrl('http://localhost/index.html') ; $response = $httpClient->execute($request); $httpStatusCode = $response->getHttpStatusCode(); $content = $response->getBodyContent();
Simple POST request
<?php use perf\HttpClient\HttpClient; $httpClient = HttpClient::createDefault(); $request = $httpClient->createRequest(); $request ->methodPost( [ 'title' => 'test article', 'content' => 'article content ...', 'photo' => $httpClient->createFile('/path/to/file.jpg') ] ) ->setUrl('http://localhost/create-article.php') ; $response = $httpClient->execute($request); $httpStatusCode = $response->getHttpStatusCode(); $content = $response->getBodyContent();
统计信息
- 总下载量: 333
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-04