allissonaraujo/sugardata
Composer 安装命令:
composer require allissonaraujo/sugardata
包简介
A simple Package to facilitate the use of requests with PHP
README 文档
README
A simple PHP package to send and receive HTTP requests using the cURL library.
Installation
To install this package, use Composer:
composer require allissonaraujo/sugardata:dev-main
Usage
Sending a POST request ⬆️
Here's a basic example of how to use the SugarData class to send a POST request:
require 'vendor/autoload.php'; use Allissonaraujo\SugarData\SugarData; $url = 'https://jsonplaceholder.typicode.com/posts'; $data = [ 'title' => 'foo', 'body' => 'bar', 'userId' => 1 ]; $request = new SugarData($url, $data); $response = $request->send(); print_r($response);
Sending a GET Request ⬇️
To send a GET request, you can specify the method as 'GET':
require 'vendor/autoload.php'; use Allissonaraujo\SugarData\SugarData; $url = 'https://jsonplaceholder.typicode.com/posts'; $data = [ 'userId' => 1 ]; $request = new SugarData($url, $data, 'GET'); $response = $request->send(); print_r($response);
Sending a PUT Request 🔄
Here's an example of how to send a PUT request:
require 'vendor/autoload.php'; use Allissonaraujo\SugarData\SugarData; $url = 'https://jsonplaceholder.typicode.com/posts/1'; $data = [ 'id' => 1, 'title' => 'foo', 'body' => 'bar', 'userId' => 1 ]; $request = new SugarData($url, $data, 'PUT'); $response = $request->send(); print_r($response);
Sending a DELETE Request ⛔
And here's how to send a DELETE request:
require 'vendor/autoload.php'; use Allissonaraujo\SugarData\SugarData; $url = 'https://jsonplaceholder.typicode.com/posts/1'; $data = []; $request = new SugarData($url, $data, 'DELETE'); $response = $request->send(); print_r($response);
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-23