dawidlisiecki/http-client

HTTP 客户端

dev-master 2023-05-11 18:09 UTC

This package is not auto-updated.

Last update: 2024-09-27 00:35:47 UTC


README

易于使用的 HTTP 客户端库。

安装

composer require dawidlisiecki/http-client

设置

use DawidLisiecki\Client;

$client = Client::withoutAuth('http://example.com');

$client->get('/endpoint');

客户端类

无授权

$client = Client::withoutAuth('http://example.com');

基本授权

$client = Client::withBasicAuth('http://example.com', 'username', 'password');

JWT 授权

$client = Client::withJWTAuth('http://example.com', 'token');

API 密钥授权

$client = Client::withAPIKey('http://example.com', 'api_key_name', 'api_key_value');

客户端方法

GET

$client->get('/endpoint', $data = []);

POST

$client->post('/endpoint', $data = []);

PUT

$client->put('/endpoint', $data = []);

DELETE

$client->delete('/endpoint', $data = []);

参数

参数类型必需
端点字符串
数据数组