overburn/http-request

CURL包装器用于Laravel

1.0.0 2016-05-05 10:01 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:38 UTC


README

Build Status Latest Stable Version Total Downloads License

安装

更新你的composer.json文件,将其作为依赖项包括在内

"overburn/http-request": "~1.0"

通过将HttpRequest服务提供者添加到config/app.php文件中的提供者数组来注册HttpRequest服务提供者。

Overburn\HttpRequest\HttpRequestServiceProvider::class

通过将HttpRequest外观添加到config/app.php文件中的别名数组来别称HttpRequest外观。

'aliases' => [
     'HttpRequest' => Overburn\HttpRequest\Facades\HttpRequest::class
]

用法

HttpRequest::request

发送请求,并返回以下形式的数组

[
	"response" => "response body given by the server",
	"info" => "the results of curl_getinfo() on the current request"
]

示例

$options = [
	"method" => "get",
	"url" => "http://www.example.com"
];

HttpRequest::request($options);

选项是一个数组

$options = [
	"method" => "get", //required - get, post, put, patch, delete
	"url" => "http://www.example.com", //required
	"params" => ["parameter"=>"value", "another" => "newvalue"], // url parameters for the request (optional)
	"data" => ["postdata[]"=>"avalue", "postdata[]"=>"anothervalue"], // data for post/put/patch/delete requests (optional, not available on "get")
	"files" => ["file" => "./example.pdf"], //an array of files (optional, not available on "get")
]