team/httpclient
最新稳定版本:1.0.1
Composer 安装命令:
composer require team/httpclient
包简介
Simple Curl wrapper utility
README 文档
README
This is a PHP HTTP client & micro-framework for building RESTful web service clients. Provides the power of Curl, with a simple to use and lightweight interface.
Fetch a page:
$x = TEAM\HttpClient\Request::get('http://birchwood.ca')
->addHeader('X-Requested-By', 'AppName')
->send();
echo $x;
Retrieve and parse JSON or XML with authentication:
$x = TEAM\HttpClient\Request::get('http://birchwood.ca/makes.json')
->setAuth('mfrank', 'twistAndShout')
->send();
// If the Content-Type is set properly:
$aJson = $x->parsed();
// otherwise...
$aJson = $x->parseAs('json');
Post a file:
$x = TEAM\HttpClient\Request::post('http://birchwood.ca', array(
'file' => new CurlFile('/tmp/resume.doc')
))->send();
Post XML body:
$x = TEAM\HttpClient\Request::post('http://birchwood.ca',
'<xml><name>Mike</name></xml>',
'application/xml')->send();
Fetch meta data from the response:
// Get a header
echo $x->getHeader('content-type');
// Read a cookie value
echo $x->getCookie('PHPSESSID');
// Get the status code
echo $x->iStatus;
Install with Composer
To install with Composer, simply require the latest version of this package.
composer require team/httpclient
统计信息
- 总下载量: 26.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2016-03-17