Skip to content

一个基于PHP cURL的开源HTTP类库,支持链式操作,省去繁杂的cURL使用方法。宇润PHP交流群:74401592

License

Notifications You must be signed in to change notification settings

lzj500/YurunHttp

 
 

Repository files navigation

YurunHttp

简介

一个基于PHP cURL的开源HTTP类库,支持链式操作,省去繁杂的cURL使用方法。

用法

GET

<?php
$http = HttpRequest::newSession();
$response = $http->get('http://www.baidu.com/');
var_dump($response);

POST(x-www-form-urlencoded)

<?php
$requestBody = array(
    'lang' => 'php',
    'ver'  => 'any'
);
$http = HttpRequest::newSession();
$response = $http->post('http://www.baidu.com/', $requestBody);
var_dump($response);

POST(raw)

<?php
$requestBody = <<<EOF
{
    'lang': 'php',
    'ver':  'any'
}
EOF;
$http = HttpRequest::newSession();
$http->contentType('application/json');
$response = $http->post('http://www.baidu.com/', $requestBody);
var_dump($response);

POST(multi_part)

<?php
$requestBody = new HttpRequestMultipartBody();
$requestBody->add('name', 'php');
$requestBody->addFile('file', '/path/to/aaa.txt', 'aaa.txt');
$http = HttpRequest::newSession();
$response = $http->post('http://www.baidu.com/', $requestBody);
var_dump($response);

具体详见Demo

About

一个基于PHP cURL的开源HTTP类库,支持链式操作,省去繁杂的cURL使用方法。宇润PHP交流群:74401592

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%