PHP Class linslin\yii2\curl\Curl

Exibir arquivo Open project: linslin/yii2-curl Class Usage Examples

Public Properties

Property Type Description
$errorCode null | integer Error code holder: https://curl.haxx.se/libcurl/c/libcurl-errors.html
$response string Holds response data right after sending a request.
$responseCharset HTTP Response Charset (taken from Content-type header)
$responseCode HTTP-Status Code This value will hold HTTP-Status Code. False if request was not successful.
$responseLength HTTP Response Length (taken from Content-length header, or strlen() of downloaded content)
$responseType HTTP Response Content Type (taken from Content-type header)

Public Methods

Method Description
delete ( string $url, boolean $raw = true ) : mixed Start performing DELETE-HTTP-Request
get ( string $url, boolean $raw = true ) : mixed Start performing GET-HTTP-Request
getInfo ( null $opt = null ) : array | mixed Get curl info according to http://php.net/manual/de/function.curl-getinfo.php
getOption ( string | integer $key ) : mixed | boolean Return a single option
getOptions ( ) : array Return merged curl options and keep keys!
head ( string $url ) : mixed Start performing HEAD-HTTP-Request
patch ( string $url, boolean $raw = true ) : mixed Start performing PATCH-HTTP-Request
post ( string $url, boolean $raw = true ) : mixed Start performing POST-HTTP-Request
put ( string $url, boolean $raw = true ) : mixed Start performing PUT-HTTP-Request
reset ( ) Total reset of options, responses, etc.
setOption ( string $key, mixed $value ) Set curl option
setOptions ( array $options ) Set curl options
unsetOption ( string $key ) Unset a single curl option
unsetOptions ( ) Unset all curl option, excluding default options.

Private Methods

Method Description
_extractAdditionalCurlParameter ( ) Extract additional curl params private class helper
_httpRequest ( string $method, string $url, boolean $raw = false ) : mixed Performs HTTP request

Method Details

delete() public method

Start performing DELETE-HTTP-Request
public delete ( string $url, boolean $raw = true ) : mixed
$url string
$raw boolean if response body contains JSON and should be decoded
return mixed response

get() public method

Start performing GET-HTTP-Request
public get ( string $url, boolean $raw = true ) : mixed
$url string
$raw boolean if response body contains JSON and should be decoded
return mixed response

getInfo() public method

Get curl info according to http://php.net/manual/de/function.curl-getinfo.php
public getInfo ( null $opt = null ) : array | mixed
$opt null
return array | mixed

getOption() public method

Return a single option
public getOption ( string | integer $key ) : mixed | boolean
$key string | integer
return mixed | boolean

getOptions() public method

Return merged curl options and keep keys!
public getOptions ( ) : array
return array

head() public method

Start performing HEAD-HTTP-Request
public head ( string $url ) : mixed
$url string
return mixed response

patch() public method

Start performing PATCH-HTTP-Request
public patch ( string $url, boolean $raw = true ) : mixed
$url string
$raw boolean if response body contains JSON and should be decoded
return mixed response

post() public method

Start performing POST-HTTP-Request
public post ( string $url, boolean $raw = true ) : mixed
$url string
$raw boolean if response body contains JSON and should be decoded
return mixed response

put() public method

Start performing PUT-HTTP-Request
public put ( string $url, boolean $raw = true ) : mixed
$url string
$raw boolean if response body contains JSON and should be decoded
return mixed response

reset() public method

Total reset of options, responses, etc.
public reset ( )

setOption() public method

Set curl option
public setOption ( string $key, mixed $value )
$key string
$value mixed

setOptions() public method

Set curl options
public setOptions ( array $options )
$options array

unsetOption() public method

Unset a single curl option
public unsetOption ( string $key )
$key string

unsetOptions() public method

Unset all curl option, excluding default options.
public unsetOptions ( )

Property Details

$errorCode public_oe property

Error code holder: https://curl.haxx.se/libcurl/c/libcurl-errors.html
public null|int $errorCode
return null | integer

$response public_oe property

Holds response data right after sending a request.
public string $response
return string

$responseCharset public_oe property

HTTP Response Charset (taken from Content-type header)
public $responseCharset

$responseCode public_oe property

HTTP-Status Code This value will hold HTTP-Status Code. False if request was not successful.
public $responseCode

$responseLength public_oe property

HTTP Response Length (taken from Content-length header, or strlen() of downloaded content)
public $responseLength

$responseType public_oe property

HTTP Response Content Type (taken from Content-type header)
public $responseType