axguowen/http-client
最新稳定版本:v1.0.1
Composer 安装命令:
composer require axguowen/http-client
包简介
Simple HTTP Client Library for PHP
README 文档
README
一个简单的HTTP客户端工具
主要功能:
发送请求
安装
composer require axguowen/http-client
用法示例
发送get请求
// 请求url $url = 'https://domain/path/'; // header参数 $headers = [ 'Content-Type' => 'application/json;charset=utf-8' ]; // 发送请求 $ret = \axguowen\HttpClient::post($url, $headers); if (!$ret->ok()) { return [null, new \axguowen\httpclient\Error($path, $ret)]; } $r = ($ret->body === null) ? [] : $ret->json();
发送post请求
// 请求url $url = 'https://domain/path/'; // 请求体 $body = [ 'id' => 1, 'page' => 2, ]; // header参数 $headers = [ 'Content-Type' => 'application/json;charset=utf-8' ]; // 发送请求 $ret = \axguowen\HttpClient::post($url, $body, $headers); if (!$ret->ok()) { return [null, new \axguowen\httpclient\Error($path, $ret)]; } $r = ($ret->body === null) ? [] : $ret->json();
统计信息
- 总下载量: 168
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 13
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-03-30