Skip to content

封装yunrunsoft-http 扩展包的主键,方便内部使用

License

Notifications You must be signed in to change notification settings

nsp-team/simple-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

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.*,.* 则代表自动识别扩展名

About

封装yunrunsoft-http 扩展包的主键,方便内部使用

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages