jaenmedina/php-rest-client
最新稳定版本:0.3.0
Composer 安装命令:
composer require jaenmedina/php-rest-client
包简介
A PHP REST Client.
README 文档
README
A PHP REST Client.
Version
0.1.0
Install with composer
Add the package dependency softiciel/php-rest-client in your composer.json
{
"require": {
"softiciel/php-rest-client": "0.3.0"
}
}
How to use?
Just instantiate the method you want to execute. There is support for GET, POST, PUT HEAD, DELETE and OPTIONS methods.
For GET method:
$url = 'http://www.example.com'; $getMethod = new Get($url); $result = $getMethod->execute(); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'.
For POST method:
$url = 'https://httpbin.org/post'; $postMethod = new Post($url); $postMethod->setParameter('text', 'Read these tips to improve'); $result = $postMethod->execute(); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'.
For PUT method:
$url = 'https://httpbin.org/put'; $putMethod = new Put($url); $data = 'Test data'; $result = $putMethod->execute($data); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'.
For HEAD method:
$url = 'http://www.example.com'; $headMethod = new Head($url); $result = $headMethod->execute(); print_r($result); // Will print the array with keys 'status', 'time', 'header', and 'error'.
For OPTIONS method:
$url = 'http://www.example.com'; $optionsMethod = new Options($url); $result = $optionsMethod->execute(); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
For DELETE method:
$url = 'https://httpbin.org/DELETE'; $deleteMethod = new Delete($url); $result = $deleteMethod->execute(); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
For custom method:
$url = 'http://www.example.com'; $customMethod = new CustomMethod($url); $result = $customMethod->execute('EXECUTE'); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
You can also use the RestClient class:
$result = RestClient::execute([ 'method' => 'get', 'url' => 'www.example.org' ]); print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
License
MIT
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-23