cURL Request Class

Work with remote servers via cURL much easier than using the native PHP bindings.

category Library
package BCA/CURL
author Brodkin CyberArts
author Philip Sturgeon
copyright 2012 Brodkin CyberArts.
license GPL-3.0 http://www.gnu.org/licenses/gpl.txt
version GIT: $Id$
link https://github.com/brodkinca/BCA-PHP-CURL

 Methods

Constructor

__construct(string $url, array $params) 

Parameters

$url

string

Valid URL resource

$params

array

Associative array of query parameters.

Destructor

__destruct() 

Set HTTP username and password

auth(string $username, string $password, string $type) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$username

string

Username.

$password

string

Password.

$type

string

Any valid value for CURLOPT_HTTPAUTH.

Returns

Set Session Cookies

cookies(array $params) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$params

array

Associative array of cookie keys and values.

Returns

DELETE HTTP Request

delete() : \BCA\CURL\Response

GET HTTP Request

get() : \BCA\CURL\Response

Set HTTP Header

header(string $header, string $content) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$header

string

Key of HTTP header.

$content

string

Value of HTTP header.

Returns

Set cURL Option

option(string $code, string $value) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$code

string

Key of cURL option to set or override.

$value

string

New value of cURL option.

Returns

Set a Parameter

param(string $key, string $value) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$key

string

Parameter key on which value should be set.

$value

string

Key on which value should be set.

Returns

Set Multiple Parameters via Array

params(array $params) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$params

array

Associative array of parameters.

Returns

POST HTTP Request

post() : \BCA\CURL\Response

PUT HTTP Request

put() : \BCA\CURL\Response

Force SSL Usage and Set SSL Options

ssl(boolean $verify_peer, integer $verify_host, string $path_to_cert) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$verify_peer

boolean

Require a valid certificate.

$verify_host

integer

Require a hostname match of certificate.

$path_to_cert

string

Local path to certificate(s) file.

Returns

Execute Request and Return Result

_execute() : mixed

Returns

mixed

Was PHP Built with cURL Support?

_hasExtCurl() : boolean

Returns

boolean

Does Instance Have a Given Option Set?

_hasOption(int $code) : boolean

Parameters

$code

int

Integer representation of cURL option.

Returns

boolean

Does Instance Have a Given Option Set?

_hasParam(string $key) : boolean

Parameters

$key

string

Key to check in parameter array.

Returns

boolean

Set HTTP Method

_method(string $method) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$method

string

Valid HTTP method.

Returns

Set cURL Multiple Options by Array

_options(array $options) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$options

array

Associative array of options and values.

Returns

Start cURL Session

_startSession(string $url) : \BCA\CURL\CURL
fluent This method is part of a fluent interface and will return the same instance

Parameters

$url

string

Valid URL resource.

Returns

 Properties

 

HTTP Headers

$headers : array
 

cURL Options

$options : array
 

Query Parameters

$params : array
 

cURL Session Handler

$session : \BCA\CURL\curl_init()
 

Base URL

$url : string