定制 craftrac/paracurl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

craftrac/paracurl

最新稳定版本:v1.0.1

Composer 安装命令:

composer require craftrac/paracurl

包简介

curl wrapper for php

README 文档

README

Paracurl is a simple PHP wrapper for making HTTP API requests using cURL. It provides an easy-to-use interface for sending GET, POST, and PUT requests, with support for basic authentication and token-based authentication.

Features

  • Supports GET, POST, and PUT HTTP methods.
  • Easily configure API endpoints and credentials via environment variables.
  • Built-in support for basic authentication or token-based authentication.
  • Simple and intuitive interface for making API calls.

Installation

To install Paracurl, you can simply add it to your project using Composer:

composer require cractrac/paracurl

Usage

You may use multiple API configurations. If the API requires basic authentication, you can use the following USERNAME and PASSWORD environment variables: Otherwise use TOKEN environment variable

PARACURL_<API_NAME>_BASEURL
PARACURL_<API_NAME>_USERNAME
PARACURL_<API_NAME>_PASSWORD
PARACURL_<API_NAME>_TOKEN

Examples

// Initialize Paracurl
$paracurl = new Paracurl('<API_NAME>', '<endpoint>');

// Send a GET request
$response = $paracurl->get();
$responseData = json_decode($response, true);

// Send a GET request with url data
$data = [
    'key' => 'value'
];
$response = $paracurl->get($data);
$responseData = json_decode($response, true);

// Send a POST request with body data
$data = [
    'key' => 'value'
];
$response = $paracurl->post($data);
$responseData = json_decode($response, true);

// Send a PUT request with body data
$data = [
    'key' => 'value'
];
$response = $paracurl->put($data);
$responseData = json_decode($response, true);

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-29