mr5/http-client

A HTTP client library, easy to use, and clear to use.

dev-master 2015-06-24 06:33 UTC

This package is not auto-updated.

Last update: 2024-03-16 13:48:09 UTC


README

中文文档

HttpClient is a library for HTTP client library which based on cURL. It has 3 class only, the HttpClient::execute() method accept a HttpClientRequest object, and return a HttpClientResponse object. Most of cURL options can be allocated with HttpClientRequest class(such as getParams, postParams, referer, cookies, user-agent and so on), and the HttpClientResponse provide most of HTTP response info, such as cookies, body, headers.

Composer

"mr5/http-client": "1.0.*@dev"

USAGE

<?php
use HttpClient\HttpClient;
use HttpClient\HttpClientRequest;
use HttpClient\HttpClientResponse;

$request = new HttpClientRequest();
$request->setUrl('https://accounts.google.com/ServiceLogin');
// Params append to url.
$request->setGetParams(array('hl'=>'zh-CN', 'continue'=>'http://www.google.com.hk'));
$request->setPostParams(array('username'=>'some username', 'password'=>'mypassword'));
$request->setMethod(HttpClientRequest::METHOD_POST);

$response = HttpClient::execute($request);

var_dump($response->getHttpStatusCode());
var_dump($response->getHeaders());
var_dump($response->getBody());
var_dump($response->getCookies());

MORE INFORMATION

For more information, please read the PHPDoc in source code .

LICENSE

MIT