PHP Класс linslin\yii2\curl\Curl

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
_extractAdditionalCurlParameter ( ) Extract additional curl params private class helper
_httpRequest ( string $method, string $url, boolean $raw = false ) : mixed Performs HTTP request

Описание методов

delete() публичный Метод

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
Результат mixed response

get() публичный Метод

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
Результат mixed response

getInfo() публичный Метод

Get curl info according to http://php.net/manual/de/function.curl-getinfo.php
public getInfo ( null $opt = null ) : array | mixed
$opt null
Результат array | mixed

getOption() публичный Метод

Return a single option
public getOption ( string | integer $key ) : mixed | boolean
$key string | integer
Результат mixed | boolean

getOptions() публичный Метод

Return merged curl options and keep keys!
public getOptions ( ) : array
Результат array

head() публичный Метод

Start performing HEAD-HTTP-Request
public head ( string $url ) : mixed
$url string
Результат mixed response

patch() публичный Метод

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
Результат mixed response

post() публичный Метод

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
Результат mixed response

put() публичный Метод

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
Результат mixed response

reset() публичный Метод

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

setOption() публичный Метод

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

setOptions() публичный Метод

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

unsetOption() публичный Метод

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

unsetOptions() публичный Метод

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

Описание свойств

$errorCode публичное свойство

Error code holder: https://curl.haxx.se/libcurl/c/libcurl-errors.html
public null|int $errorCode
Результат null | integer

$response публичное свойство

Holds response data right after sending a request.
public string $response
Результат string

$responseCharset публичное свойство

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

$responseCode публичное свойство

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

$responseLength публичное свойство

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

$responseType публичное свойство

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