aayush / hit-api
使用 cURL 进行 HTTP 请求的简单 PHP 类。
v1.1.0
2024-09-03 21:08 UTC
Requires
- php: ^7.4|^8.0
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-03 21:15:28 UTC
README
HitApi
是一个用于通过 cURL
进行 HTTP 请求的 PHP 辅助类。它简化了发送 GET、POST、PUT 和 DELETE 请求的过程,并提供可定制的头和有效载荷。
安装
要使用 HitApi
,您需要在 PHP 环境中启用 cURL
。只需将 HitApi.php
文件包含到您的项目中,然后按照以下使用说明操作。
使用方法
基本使用
-
初始化:首先使用所需的端点初始化
HitApi
。use App\Helpers\HitApi; $response = HitApi::to('/endpoint') ->withHeader('Authorization', 'Bearer YOUR_TOKEN') ->withPayload(['key' => 'value']) ->get(); // Use get(), post(), put(), or delete() based on your needs
-
初始化:首先使用所需的端点初始化
HitApi
。use App\Helpers\HitApi; $response = HitApi::to('/endpoint') ->withHeaders(['Authorization' => 'Bearer YOUR_TOKEN']) ->withPayload(['key' => 'value']) ->post(); // Use get(), post(), put(), or delete() based on your needs
如何安装
composer require aayush/hit-api