2017 © Pedro Peláez
 

library curl

VolumNet implementation for CURL

image

volumnet/curl

VolumNet implementation for CURL

  • Monday, January 29, 2018
  • by volumnet
  • Repository
  • 1 Watchers
  • 0 Stars
  • 50 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

VolumNet implementation of CURL

Installation

composer require volumnet/curl

Default params

By default VolumNet CURL uses the following params:, (*1)

  • Request timeout: 30s
  • User agent string: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
  • Cookie file: not used

Usage

/**
 * @param int $timeout Timeout in seconds
 * @param string $userAgent User agent string
 * @param string $cookieFile Cookie file path
 */ 
$curl = new CURL(10, 'My User Agent', 'cookie.txt');

$curl->timeout = 25;
$curl->userAgent = 'Their User Agent';
$curl->cookieFile = 'cookie2.txt';

/**
 * Connects to URL
 * @param string $url URL to connect
 * @param array $data POST-data (if empty, GET protocol will be used)
 * @param boolean $withHeaders return both headers and response text in array
 * @param 'text'|'json'|'jsonObject'|'jsonArray'|'phpquery' $outputFormat Output format
 * @return string|array(array<string> $headers, mixed $response) Response text or array of headers' array and response text
 */
$result = $curl->getURL('http://httpbin.org/get?aaa=bbb', array(), true, 'jsonArray');

/**
 * Response:
 * Array
 * (
 *     [0] => Array
 *         (
 *             [HTTP/1.1 200 OK] =>
 *             [Connection] => keep-alive
 *             [Server] => meinheld/0.6.1
 *             [Date] => Mon, 08 Jan 2018 13:14:42 GMT
 *             [Content-Type] => application/json
 *             [Access-Control-Allow-Origin] => *
 *             [Access-Control-Allow-Credentials] => true
 *             [X-Powered-By] => Flask
 *             [X-Processed-Time] => 0.00164794921875
 *             [Content-Length] => 507
 *             [Via] => 1.1 vegur
 *             [] =>
 *         )
 *     [1] => Array
 *         (
 *             [args] => Array
 *                 (
 *                     [aaa] => bbb
 *                 )
 *             [headers] => Array
 *                 (
 *                     [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp;q=0.8
 *                     [Accept-Language] => ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
 *                     [Cache-Control] => max-age=0
 *                     [Connection] => close
 *                     [Host] => httpbin.org
 *                     [User-Agent] => Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
 *                 )
 *             [url] => http://httpbin.org/get?aaa=bbb
 *         )
 * )
 */

$result = $curl->getURL('https://httpbin.org/post?aaa=bbb', array('ccc' => 'ddd'), false, 'jsonObject');
/**
 * Response:
 * stdClass Object
 * (
 *     [args] => stdClass Object
 *         (
 *             [aaa] => bbb
 *         )
 *     [data] =>
 *     [files] => stdClass Object
 *         (
 *         )
 *     [form] => stdClass Object
 *         (
 *             [ccc] => ddd
 *         )
 *     [headers] => stdClass Object
 *         (
 *             [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp;q=0.8
 *             [Accept-Language] => ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
 *             [Cache-Control] => max-age=0
 *             [Connection] => close
 *             [Content-Length] => 7
 *             [Content-Type] => application/x-www-form-urlencoded
 *             [Host] => httpbin.org
 *             [User-Agent] => Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
 *         )
 *     [json] =>
 *     [url] => https://httpbin.org/post?aaa=bbb
 * )
 */

The Versions

29/01 2018

dev-master

9999999-dev

VolumNet implementation for CURL

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Alex V. Surnin

29/01 2018

1.0.5

1.0.5.0

VolumNet implementation for CURL

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Alex V. Surnin

08/01 2018

1.0.0

1.0.0.0

VolumNet implementation for CURL

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Alex V. Surnin