https://github.com/fishtailstudio/http
Http GET and POST methods.
https://github.com/fishtailstudio/http
Last synced: 5 months ago
JSON representation
Http GET and POST methods.
- Host: GitHub
- URL: https://github.com/fishtailstudio/http
- Owner: fishtailstudio
- License: apache-2.0
- Created: 2020-07-26T03:34:57.000Z (almost 6 years ago)
- Default Branch: dev
- Last Pushed: 2020-08-21T04:25:19.000Z (almost 6 years ago)
- Last Synced: 2025-07-30T06:02:28.088Z (11 months ago)
- Language: PHP
- Homepage: https://packagist.org/packages/fishtail/http
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
##### 经常在项目里面会用上GET和POST请求方法,使用封装好的方法会方便很多。
## 一、安装
```shell
composer require fishtail/http
```
## 二、使用
### 1. 导入
```php
use Fishtail\Http;
```
### 2. GET请求
```php
$res = Http::get('https://www.baidu.com');
```
### 3. POST请求
```php
$url = 'http://example.com';
$header = [
'Accept: */*',
'Content-Type: text/plain;charset=UTF-8'
];
$cookie = 'token=2f2568ae-75f0-4ba9-98d4-8c139dad7f64';
$postData = [
'page' => 1,
'pageSize' => 20
];
$res = Http::post($url, $postData, $cookie, $header);
```
## 三、参数解释
### 1. GET方法
| 参数 | 类型 | 描述 |
| :------------ | :------------ | :------------ |
| url | string | 请求的url |
| cookie | string | 请求cookie |
| header | array | 请求头数据 |
| returnCookie | bool | 是否返回cookie |
### 1. POST方法
| 参数 | 类型 | 描述 |
| :------------ | :------------ | :------------ |
| url | string | 请求的url |
| data | string\|array | post数据 |
| cookie | string | 请求cookie |
| header | array | 请求头数据 |
| returnCookie | bool | 是否返回cookie |