2017 © Pedro Peláez
 

library httpclient

It is a PHP wrapper for curl.

image

urmaul/httpclient

It is a PHP wrapper for curl.

  • Thursday, July 7, 2016
  • by urmaul
  • Repository
  • 2 Watchers
  • 5 Stars
  • 17,269 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 10 % Grown

The README.md

Php Http Client

It is a PHP wrapper for curl., (*1)

The main idea was just to make HTTP requests with one-liners. And cookie support out-of-the box., (*2)

For something more complex you probably want Guzzle., (*3)

Build Status, (*4)

How to use

Like that., (*5)

HttpClient::from(['useRandomCookieFile' => true])->get('http://httpbin.org/get');

HttpClient::from()->post('http://httpbin.org/post', ['foo' => 'bar']);

HttpClient::from()->download('http://httpbin.org/image/jpeg', 'my-new-image-file.jpeg');

Methods

  • head($url, $params = array()) - performs http request to get responce headers.
  • get($url, $params = array()) - performs http GET request.
  • post($url, $post = array(), $params = array()) - performs http POST request.
  • download($url, $dest, $post = array(), $params = array()) - downloads file.
  • request($params) - performs http request.
  • getInfo($opt = null) - Returns information about the last transfer. Details

Possible $params values

  • url - (string) request url.
  • post - (string|array) request POST data.
  • ref - (string) "Referer" request header content.
  • header - (boolean, default = false) whether to include response header into response.
  • nobody - (boolean, default = false) whether to NOT include response body into response.
  • timeout - (integer, default = 15) request timeout.
  • tofile - (string, default = null) output file name. If defined - response will be saved to that file.
  • attempts_max - (integer, default = 1) maximum number of attempts to perform HTTP request.
  • attempts_delay - (integer, default = 10) delay between attempts, in seconds

Readonly properties

  • $lastError - (string) last request error.
  • $info - (array) information about the last transfer.
  • $httpCode - (integer) last received HTTP code.
  • $effectiveUrl - (string) last effective url.
  • $cookies - (array) cookies array. Warning, after calling this property you will be not able to get another properties.

The Versions

07/07 2016

dev-master

9999999-dev https://github.com/urmaul/httpclient

It is a PHP wrapper for curl.

  Sources   Download

MIT

The Requires

  • lib-curl *
  • php >=5.3

 

The Development Requires

httpclient

07/07 2016

1.1.1

1.1.1.0 https://github.com/urmaul/httpclient

It is a PHP wrapper for curl.

  Sources   Download

MIT

The Requires

  • php >=5.3
  • lib-curl *

 

The Development Requires

httpclient

25/01 2015

v1.1.0

1.1.0.0 https://github.com/urmaul/httpclient

It is a PHP wrapper for curl.

  Sources   Download

MIT

The Requires

  • php >=5.3
  • lib-curl *

 

The Development Requires

httpclient

13/10 2014

v1.0.0

1.0.0.0 https://github.com/urmaul/httpclient

It is a PHP wrapper for curl.

  Sources   Download

MIT

The Requires

  • php >=5.3
  • lib-curl *

 

The Development Requires

httpclient