nsp-team / simple-http
http request
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nsp-team/simple-http
Requires
- php: >=7.3
- yurunsoft/yurun-http: ^4.3.0
This package is auto-updated.
Last update: 2025-09-29 02:58:43 UTC
README
A PHP library to work with http request. dependent on https://github.com/Yurunsoft/YurunHttp/
Installation
This library is installable via composer
composer require nsp-team/simple-http
Usage
<?php require dirname(__DIR__) . '/vendor/autoload.php'; use Yurun\Util\YurunHttp\Http\Psr7\UploadedFile; use Yurun\Util\YurunHttp\Http\Psr7\Consts\MediaType; $response = \NspTeam\HttpClient::create()->get('https://www.baidu.com'); $response = \NspTeam\HttpClient::create() ->withHeaders([ 'content-type' => 'application/json' ]) // 同时支持POST参数、上传文件 ->withContent([ 'lang' => 'php', 'ver' => 'any', 'file' => new \Yurun\Util\YurunHttp\Http\Psr7\UploadedFile('1.txt', MediaType::TEXT_PLAIN, __FILE__), ]) ->post('https://www.baidu.com'); $url = 'https://www.baidu.com' $response = \NspTeam\HttpClient::create()->download(__DIR__ . '/save.*', $url); // 如果文件名设为save.*,.* 则代表自动识别扩展名