Giter Site home page Giter Site logo

curlhttp's Introduction

#CurlHttp Total Downloads Latest Stable Version Travis Build SensioLabs Insight

The simplest cURL HTTP client for PHP

##Install Via composer: $ composer require "phpcurl/curlhttp"

##Usage

<?php
use PHPCurl\CurlHttp\HttpClient;

$http = new HttpClient();

$response = $http->post('http://example.com/?a=b', 'my post data', ['User-Agent: My php crawler']);
// Supported: get(), post(), head(), post(), put(), delete()

$body = $response->getBody(); // Response body, string

/*

<!doctype html>
<html>
...
</html>

 */

$statusCode = $response->getStatus(); // HTTP status, int

/*

200

 */

$headers = $response->getHeaders(); // HTTP response headers, array
/*

array(
  0 => 'HTTP/1.1 200 OK',
  1 => 'Accept-Ranges: bytes',
  2 => 'Cache-Control: max-age=604800',
  3 => 'Content-Type: text/html',
  4 => 'Date: Wed, 03 Feb 2016 07:01:58 GMT',
  5 => 'Etag: "359670651"',
  6 => 'Expires: Wed, 10 Feb 2016 07:01:58 GMT',
  7 => 'Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT',
  8 => 'Server: ECS (rhv/818F)',
  9 => 'Vary: Accept-Encoding',
  10 => 'X-Cache: HIT',
  11 => 'x-ec-custom-error: 1',
  12 => 'Content-Length: 1270',
);

 */

curlhttp's People

Contributors

f3ath avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.