PHP Class Curl\Curl

Mostra file Open project: php-curl-class/php-curl-class Class Usage Examples

Public Properties

Property Type Description
$RFC2616
$RFC6265
$baseUrl
$beforeSendFunction
$completeFunction
$curl
$curlError
$curlErrorCode
$curlErrorMessage
$downloadCompleteFunction
$error
$errorCode
$errorFunction
$errorMessage
$fileHandle
$httpError
$httpErrorMessage
$httpStatusCode
$id
$rawResponse
$rawResponseHeaders
$requestHeaders
$response
$responseCookies
$responseHeaders
$successFunction
$url

Public Methods

Method Description
__construct ( $base_url = null ) Construct
__destruct ( ) Destruct
__get ( $name )
array_flatten_multidim ( $array, $prefix = false ) : array Array Flatten Multidim
beforeSend ( $callback ) Before Send
buildPostData ( $data ) : array | string Build Post Data
call ( ) Call
close ( ) Close
complete ( $callback ) Complete
delete ( $url, $query_parameters = [], $data = [] ) : string Delete
download ( $url, $mixed_filename ) : boolean Download
error ( $callback ) Error
exec ( $ch = null ) : mixed Exec
get ( $url, $data = [] ) : mixed Get
getCookie ( $key ) : mixed Get Cookie
getInfo ( $opt = null ) : mixed Get Info
getOpt ( $option ) : mixed Get Opt
getResponseCookie ( $key ) : mixed Get Response Cookie
head ( $url, $data = [] ) : string Head
headerCallback ( $ch, $header ) : integer Header Callback
is_array_assoc ( $array ) : boolean Is Array Assoc
is_array_multidim ( $array ) : boolean Is Array Multidim
options ( $url, $data = [] ) : string Options
patch ( $url, $data = [] ) : string Patch
post ( $url, $data = [], $follow_303_with_post = false ) : string Post
progress ( $callback ) Progress
put ( $url, $data = [] ) : string Put
removeHeader ( $key ) Remove Header
search ( $url, $data = [] ) : string Search
setBasicAuthentication ( $username, $password = '' ) Set Basic Authentication
setConnectTimeout ( $seconds ) Set Connect Timeout
setCookie ( $key, $value ) Set Cookie
setCookieFile ( $cookie_file ) Set Cookie File
setCookieJar ( $cookie_jar ) Set Cookie Jar
setCookieString ( $string ) : boolean Set Cookie String
setDefaultDecoder ( $decoder = 'json' ) Set Default Decoder
setDefaultJsonDecoder ( ) Set Default JSON Decoder
setDefaultTimeout ( ) Set Default Timeout
setDefaultUserAgent ( ) Set Default User Agent
setDefaultXmlDecoder ( ) Set Default XML Decoder
setDigestAuthentication ( $username, $password = '' ) Set Digest Authentication
setHeader ( $key, $value ) Set Header
setHeaders ( $headers ) Set Headers
setJsonDecoder ( $function ) Set JSON Decoder
setMaxFilesize ( $bytes ) Set Max Filesize
setOpt ( $option, $value ) : boolean Set Opt
setOpts ( $options ) : boolean Set Opts
setPort ( $port ) Set Port
setReferer ( $referer ) Set Referer
setReferrer ( $referrer ) Set Referrer
setTimeout ( $seconds ) Set Timeout
setUrl ( $url, $data = [] ) Set Url
setUserAgent ( $user_agent ) Set User Agent
setXmlDecoder ( $function ) Set XML Decoder
success ( $callback ) Success
unsetHeader ( $key ) Unset Header
verbose ( boolean $on = true, resource $output = STDERR ) Verbose

Private Methods

Method Description
__get_effectiveUrl ( ) Get Effective Url
__get_rfc2616 ( ) Get RFC 2616
__get_rfc6265 ( ) Get RFC 6265
__get_totalTime ( ) Get Total Time
buildURL ( $url, $data = [] ) : string Build Url
downloadComplete ( $fh ) Download Complete
parseHeaders ( $raw_headers ) : array Parse Headers
parseRequestHeaders ( $raw_headers ) : array Parse Request Headers
parseResponse ( $response_headers, $raw_response ) : mixed Parse Response
parseResponseHeaders ( $raw_response_headers ) : array Parse Response Headers

Method Details

__construct() public method

Construct
public __construct ( $base_url = null )
$base_url

__destruct() public method

Destruct
public __destruct ( )

__get() public method

public __get ( $name )

array_flatten_multidim() public static method

Array Flatten Multidim
public static array_flatten_multidim ( $array, $prefix = false ) : array
$array
$prefix
return array

beforeSend() public method

Before Send
public beforeSend ( $callback )
$callback

buildPostData() public method

Build Post Data
public buildPostData ( $data ) : array | string
$data
return array | string

call() public method

Call
public call ( )

close() public method

Close
public close ( )

complete() public method

Complete
public complete ( $callback )
$callback

delete() public method

Delete
public delete ( $url, $query_parameters = [], $data = [] ) : string
$url
$query_parameters
$data
return string

download() public method

Download
public download ( $url, $mixed_filename ) : boolean
$url
$mixed_filename
return boolean

error() public method

Error
public error ( $callback )
$callback

exec() public method

Exec
public exec ( $ch = null ) : mixed
$ch
return mixed Returns the value provided by parseResponse.

get() public method

Get
public get ( $url, $data = [] ) : mixed
$url
$data
return mixed Returns the value provided by exec.

getCookie() public method

Get Cookie
public getCookie ( $key ) : mixed
$key
return mixed

getInfo() public method

Get Info
public getInfo ( $opt = null ) : mixed
$opt
return mixed

getOpt() public method

Get Opt
public getOpt ( $option ) : mixed
$option
return mixed

getResponseCookie() public method

Get Response Cookie
public getResponseCookie ( $key ) : mixed
$key
return mixed

head() public method

Head
public head ( $url, $data = [] ) : string
$url
$data
return string

headerCallback() public method

Header Callback
public headerCallback ( $ch, $header ) : integer
$ch
$header
return integer

is_array_assoc() public static method

Is Array Assoc
public static is_array_assoc ( $array ) : boolean
$array
return boolean

is_array_multidim() public static method

Is Array Multidim
public static is_array_multidim ( $array ) : boolean
$array
return boolean

options() public method

Options
public options ( $url, $data = [] ) : string
$url
$data
return string

patch() public method

Patch
public patch ( $url, $data = [] ) : string
$url
$data
return string

post() public method

Post
public post ( $url, $data = [], $follow_303_with_post = false ) : string
$url
$data
$follow_303_with_post If true, will cause 303 redirections to be followed using a POST request (default: false). Notes: - Redirections are only followed if the CURLOPT_FOLLOWLOCATION option is set to true. - According to the HTTP specs (see [1]), a 303 redirection should be followed using the GET method. 301 and 302 must not. - In order to force a 303 redirection to be performed using the same method, the underlying cURL object must be set in a special state (the CURLOPT_CURSTOMREQUEST option must be set to the method to use after the redirection). Due to a limitation of the cURL extension of PHP < 5.5.11 ([2], [3]) and of HHVM, it is not possible to reset this option. Using these PHP engines, it is therefore impossible to restore this behavior on an existing php-curl-class Curl object.
return string [1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2 [2] https://github.com/php/php-src/pull/531 [3] http://php.net/ChangeLog-5.php#5.5.11

progress() public method

Progress
public progress ( $callback )
$callback

put() public method

Put
public put ( $url, $data = [] ) : string
$url
$data
return string

removeHeader() public method

Remove an internal header from the request. Using `curl -H "Host:" ...' is equivalent to $curl->removeHeader('Host');.
public removeHeader ( $key )
$key

setBasicAuthentication() public method

Set Basic Authentication
public setBasicAuthentication ( $username, $password = '' )
$username
$password

setConnectTimeout() public method

Set Connect Timeout
public setConnectTimeout ( $seconds )
$seconds

setCookie() public method

Set Cookie
public setCookie ( $key, $value )
$key
$value

setCookieFile() public method

Set Cookie File
public setCookieFile ( $cookie_file )
$cookie_file

setCookieJar() public method

Set Cookie Jar
public setCookieJar ( $cookie_jar )
$cookie_jar

setCookieString() public method

Set Cookie String
public setCookieString ( $string ) : boolean
$string
return boolean

setDefaultDecoder() public method

Set Default Decoder
public setDefaultDecoder ( $decoder = 'json' )
$decoder string|callable

setDefaultJsonDecoder() public method

Set Default JSON Decoder

setDefaultTimeout() public method

Set Default Timeout
public setDefaultTimeout ( )

setDefaultUserAgent() public method

Set Default User Agent
public setDefaultUserAgent ( )

setDefaultXmlDecoder() public method

Set Default XML Decoder

setDigestAuthentication() public method

Set Digest Authentication
public setDigestAuthentication ( $username, $password = '' )
$username
$password

setHeader() public method

Add extra header to include in the request.
public setHeader ( $key, $value )
$key
$value

setHeaders() public method

Add extra headers to include in the request.
public setHeaders ( $headers )
$headers

setJsonDecoder() public method

Set JSON Decoder
public setJsonDecoder ( $function )
$function

setMaxFilesize() public method

Set Max Filesize
public setMaxFilesize ( $bytes )
$bytes

setOpt() public method

Set Opt
public setOpt ( $option, $value ) : boolean
$option
$value
return boolean

setOpts() public method

Set Opts
public setOpts ( $options ) : boolean
$options
return boolean Returns true if all options were successfully set. If an option could not be successfully set, false is immediately returned, ignoring any future options in the options array. Similar to curl_setopt_array().

setPort() public method

Set Port
public setPort ( $port )
$port

setReferer() public method

Set Referer
public setReferer ( $referer )
$referer

setReferrer() public method

Set Referrer
public setReferrer ( $referrer )
$referrer

setTimeout() public method

Set Timeout
public setTimeout ( $seconds )
$seconds

setUrl() public method

Set Url
public setUrl ( $url, $data = [] )
$url
$data

setUserAgent() public method

Set User Agent
public setUserAgent ( $user_agent )
$user_agent

setXmlDecoder() public method

Set XML Decoder
public setXmlDecoder ( $function )
$function

success() public method

Success
public success ( $callback )
$callback

unsetHeader() public method

Remove extra header previously set using Curl::setHeader().
public unsetHeader ( $key )
$key

verbose() public method

Verbose
public verbose ( boolean $on = true, resource $output = STDERR )
$on boolean
$output resource

Property Details

$RFC2616 public_oe static_oe property

public static $RFC2616

$RFC6265 public_oe static_oe property

public static $RFC6265

$baseUrl public_oe property

public $baseUrl

$beforeSendFunction public_oe property

public $beforeSendFunction

$completeFunction public_oe property

public $completeFunction

$curl public_oe property

public $curl

$curlError public_oe property

public $curlError

$curlErrorCode public_oe property

public $curlErrorCode

$curlErrorMessage public_oe property

public $curlErrorMessage

$downloadCompleteFunction public_oe property

public $downloadCompleteFunction

$error public_oe property

public $error

$errorCode public_oe property

public $errorCode

$errorFunction public_oe property

public $errorFunction

$errorMessage public_oe property

public $errorMessage

$fileHandle public_oe property

public $fileHandle

$httpError public_oe property

public $httpError

$httpErrorMessage public_oe property

public $httpErrorMessage

$httpStatusCode public_oe property

public $httpStatusCode

$id public_oe property

public $id

$rawResponse public_oe property

public $rawResponse

$rawResponseHeaders public_oe property

public $rawResponseHeaders

$requestHeaders public_oe property

public $requestHeaders

$response public_oe property

public $response

$responseCookies public_oe property

public $responseCookies

$responseHeaders public_oe property

public $responseHeaders

$successFunction public_oe property

public $successFunction

$url public_oe property

public $url