PHP Class Pop\Curl\Curl

Author: Nick Sagona, III ([email protected])
Mostra file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$body string Response body
$code integer Response code
$curl cURL resource
$fields array Fields
$header string Raw response header
$headerSize integer Raw response header size
$headers array Response headers
$message string Response message
$options array cURL options
$response string Response string
$version string HTTP version from response

Public Methods

Method Description
__construct ( string $url, array $opts = null ) : Curl Constructor
__destruct ( ) : void Close the cURL session.
execute ( ) : mixed Execute the cURL session.
getBody ( ) : string Get the cURL response body
getCode ( ) : string Get the cURL response code
getField ( string $name ) : mixed Get a field
getFields ( ) : array Get all field
getHeader ( string $name ) : mixed Get a response header
getHeaders ( ) : array Get all response headers
getHttpVersion ( ) : string Get the cURL response HTTP version
getInfo ( integer $opt = null ) : array | string Return the cURL session last info.
getMessage ( ) : string Get the cURL response HTTP message
getOption ( integer $opt ) : string Get a cURL session option.
getRawHeader ( ) : string Get raw response header
getResponse ( ) : string Get the full cURL response
isPost ( ) : boolean Check if cURL is set to POST
isReturnHeader ( ) : boolean Check if cURL is set to return header
isReturnTransfer ( ) : boolean Check if cURL is set to return transfer
setField ( string $name, mixed $value ) : Curl Set a field
setFields ( array $fields ) : Curl Set all fields
setOption ( array | integer $opt, string $val = null ) : Curl Set cURL session option(s).
setPost ( boolean $post = false ) : Curl Set cURL option for POST
setReturnHeader ( boolean $header = false ) : Curl Set cURL option to return the header
setReturnTransfer ( boolean $transfer = false ) : Curl Set cURL option to return the transfer
version ( ) : array Return the cURL version.

Protected Methods

Method Description
parseHeaders ( ) : void Parse headers
showError ( ) : void Throw an exception upon a cURL error.

Method Details

__construct() public method

Instantiate the cURL object.
public __construct ( string $url, array $opts = null ) : Curl
$url string
$opts array
return Curl

__destruct() public method

Close the cURL session.
public __destruct ( ) : void
return void

execute() public method

Execute the cURL session.
public execute ( ) : mixed
return mixed

getBody() public method

Get the cURL response body
public getBody ( ) : string
return string

getCode() public method

Get the cURL response code
public getCode ( ) : string
return string

getField() public method

Get a field
public getField ( string $name ) : mixed
$name string
return mixed

getFields() public method

Get all field
public getFields ( ) : array
return array

getHeader() public method

Get a response header
public getHeader ( string $name ) : mixed
$name string
return mixed

getHeaders() public method

Get all response headers
public getHeaders ( ) : array
return array

getHttpVersion() public method

Get the cURL response HTTP version
public getHttpVersion ( ) : string
return string

getInfo() public method

Return the cURL session last info.
public getInfo ( integer $opt = null ) : array | string
$opt integer
return array | string

getMessage() public method

Get the cURL response HTTP message
public getMessage ( ) : string
return string

getOption() public method

Get a cURL session option.
public getOption ( integer $opt ) : string
$opt integer
return string

getRawHeader() public method

Get raw response header
public getRawHeader ( ) : string
return string

getResponse() public method

Get the full cURL response
public getResponse ( ) : string
return string

isPost() public method

Check if cURL is set to POST
public isPost ( ) : boolean
return boolean

isReturnHeader() public method

Check if cURL is set to return header
public isReturnHeader ( ) : boolean
return boolean

isReturnTransfer() public method

Check if cURL is set to return transfer
public isReturnTransfer ( ) : boolean
return boolean

parseHeaders() protected method

Parse headers
protected parseHeaders ( ) : void
return void

setField() public method

Set a field
public setField ( string $name, mixed $value ) : Curl
$name string
$value mixed
return Curl

setFields() public method

Set all fields
public setFields ( array $fields ) : Curl
$fields array
return Curl

setOption() public method

Set cURL session option(s).
public setOption ( array | integer $opt, string $val = null ) : Curl
$opt array | integer
$val string
return Curl

setPost() public method

Set cURL option for POST
public setPost ( boolean $post = false ) : Curl
$post boolean
return Curl

setReturnHeader() public method

Set cURL option to return the header
public setReturnHeader ( boolean $header = false ) : Curl
$header boolean
return Curl

setReturnTransfer() public method

Set cURL option to return the transfer
public setReturnTransfer ( boolean $transfer = false ) : Curl
$transfer boolean
return Curl

showError() protected method

Throw an exception upon a cURL error.
protected showError ( ) : void
return void

version() public method

Return the cURL version.
public version ( ) : array
return array

Property Details

$body protected_oe property

Response body
protected string $body
return string

$code protected_oe property

Response code
protected int $code
return integer

$curl protected_oe property

cURL resource
protected $curl

$fields protected_oe property

Fields
protected array $fields
return array

$header protected_oe property

Raw response header
protected string $header
return string

$headerSize protected_oe property

Raw response header size
protected int $headerSize
return integer

$headers protected_oe property

Response headers
protected array $headers
return array

$message protected_oe property

Response message
protected string $message
return string

$options protected_oe property

cURL options
protected array $options
return array

$response protected_oe property

Response string
protected string $response
return string

$version protected_oe property

HTTP version from response
protected string $version
return string