Documentation

Curl extends AbstractClient
in package

HTTP curl client class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2021 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.1.0

Table of Contents

$method  : string
Method
$options  : array<string|int, mixed>
cURL options
$request  : Request
Client request object
$resource  : resource
Client resource object
$response  : Response
Client response object
$url  : string
URL
__construct()  : mixed
Constructor
addRequestHeader()  : AbstractClient
Add request header
addRequestHeaders()  : AbstractClient
Add request headers
addResponseHeader()  : AbstractClient
Add response header
addResponseHeaders()  : AbstractClient
Add response headers
createAsJson()  : AbstractClient
Create request as JSON
createMultipartForm()  : AbstractClient
Create request as a multipart form
createUrlEncodedForm()  : AbstractClient
Create request as a URL-encoded form
curl()  : resource
Return cURL resource (alias to $this->getResource())
disconnect()  : void
Close the cURL connection
getField()  : mixed
Get a field
getFields()  : array<string|int, mixed>
Get all field
getInfo()  : array<string|int, mixed>|string
Return the cURL session last info
getMethod()  : string
Get the method
getOption()  : string
Get a cURL session option
getParsedResponse()  : mixed
Get the parsed response
getRequest()  : Request
Get the request object
getRequestBody()  : string
Get the request body
getRequestHeader()  : mixed
Get the request header
getRequestHeaders()  : array<string|int, mixed>
Get the request headers
getResource()  : resource
Get the resource
getResponse()  : Response
Get the response object
getResponseBody()  : string
Get the response body
getResponseCode()  : string
Get the response code
getResponseHeader()  : mixed
Get the response header
getResponseHeaders()  : array<string|int, mixed>
Get the response headers
getUrl()  : string
Get the URL
hasOption()  : bool
Has a cURL session option
hasRequest()  : bool
Has request object
hasRequestHeader()  : bool
Has request header
hasRequestHeaders()  : bool
Has request headers
hasResource()  : bool
Determine whether or not resource is available
hasResponse()  : bool
Has response object
hasResponseHeader()  : bool
Has response header
hasResponseHeaders()  : bool
Has response headers
isJson()  : bool
Check if request is JSON
isMultipartForm()  : bool
Check if request is a multipart form
isReturnHeader()  : bool
Check if cURL is set to return header
isReturnTransfer()  : bool
Check if cURL is set to return transfer
isUrlEncodedForm()  : bool
Check if request is a URL-encoded form
open()  : Curl
Create and open cURL resource
removeField()  : AbstractClient
Remove a field
removeFields()  : AbstractClient
Remove all fields
request()  : Request
Get the request object (alias method)
resource()  : resource
Get the resource (alias method)
response()  : Response
Get the response object (alias method)
send()  : void
Method to send the request and get the response
setField()  : AbstractClient
Set a field
setFields()  : AbstractClient
Set all fields
setMethod()  : Curl
Set the method
setOption()  : Curl
Set cURL session option
setOptions()  : Curl
Set cURL session options
setRequest()  : AbstractClient
Set the request object
setResponse()  : AbstractClient
Set the response object
setReturnHeader()  : Curl
Set cURL option to return the header
setReturnTransfer()  : Curl
Set cURL option to return the transfer
setUrl()  : AbstractClient
Set the URL
throwError()  : void
Throw an exception upon an error.
version()  : array<string|int, mixed>
Return the cURL version

Properties

$options

cURL options

protected array<string|int, mixed> $options = []

$resource

Client resource object

protected resource $resource = null

Methods

__construct()

Constructor

public __construct([string $url = null ][, string $method = 'GET' ][, array<string|int, mixed> $opts = null ]) : mixed

Instantiate the cURL object

Parameters
$url : string = null
$method : string = 'GET'
$opts : array<string|int, mixed> = null
Tags
throws
Exception
Return values
mixed

curl()

Return cURL resource (alias to $this->getResource())

public curl() : resource
Return values
resource

disconnect()

Close the cURL connection

public disconnect() : void
Return values
void

getField()

Get a field

public getField(string $name) : mixed
Parameters
$name : string
Return values
mixed

getFields()

Get all field

public getFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getInfo()

Return the cURL session last info

public getInfo([int $opt = null ]) : array<string|int, mixed>|string
Parameters
$opt : int = null
Return values
array<string|int, mixed>|string

getMethod()

Get the method

public getMethod() : string
Return values
string

getOption()

Get a cURL session option

public getOption(int $opt) : string
Parameters
$opt : int
Return values
string

getParsedResponse()

Get the parsed response

public getParsedResponse() : mixed
Return values
mixed

getRequestBody()

Get the request body

public getRequestBody() : string
Return values
string

getRequestHeader()

Get the request header

public getRequestHeader(string $name) : mixed
Parameters
$name : string
Return values
mixed

getRequestHeaders()

Get the request headers

public getRequestHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getResource()

Get the resource

public getResource() : resource
Return values
resource

getResponseBody()

Get the response body

public getResponseBody() : string
Return values
string

getResponseCode()

Get the response code

public getResponseCode() : string
Return values
string

getResponseHeader()

Get the response header

public getResponseHeader(string $name) : mixed
Parameters
$name : string
Return values
mixed

getResponseHeaders()

Get the response headers

public getResponseHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUrl()

Get the URL

public getUrl() : string
Return values
string

hasOption()

Has a cURL session option

public hasOption(int $opt) : bool
Parameters
$opt : int
Return values
bool

hasRequest()

Has request object

public hasRequest() : bool
Return values
bool

hasRequestHeader()

Has request header

public hasRequestHeader(string $name) : bool
Parameters
$name : string
Return values
bool

hasRequestHeaders()

Has request headers

public hasRequestHeaders() : bool
Return values
bool

hasResource()

Determine whether or not resource is available

public hasResource() : bool
Return values
bool

hasResponse()

Has response object

public hasResponse() : bool
Return values
bool

hasResponseHeader()

Has response header

public hasResponseHeader(string $name) : bool
Parameters
$name : string
Return values
bool

hasResponseHeaders()

Has response headers

public hasResponseHeaders() : bool
Return values
bool

isJson()

Check if request is JSON

public isJson() : bool
Return values
bool

isMultipartForm()

Check if request is a multipart form

public isMultipartForm() : bool
Return values
bool

isReturnHeader()

Check if cURL is set to return header

public isReturnHeader() : bool
Return values
bool

isReturnTransfer()

Check if cURL is set to return transfer

public isReturnTransfer() : bool
Return values
bool

isUrlEncodedForm()

Check if request is a URL-encoded form

public isUrlEncodedForm() : bool
Return values
bool

open()

Create and open cURL resource

public open() : Curl
Return values
Curl

resource()

Get the resource (alias method)

public resource() : resource
Return values
resource

send()

Method to send the request and get the response

public send() : void
Return values
void

setMethod()

Set the method

public setMethod(string $method[, bool $strict = true ]) : Curl
Parameters
$method : string
$strict : bool = true
Tags
throws
Exception
Return values
Curl

setOption()

Set cURL session option

public setOption(int $opt, mixed $val) : Curl
Parameters
$opt : int
$val : mixed
Return values
Curl

setOptions()

Set cURL session options

public setOptions(array<string|int, mixed> $opts) : Curl
Parameters
$opts : array<string|int, mixed>
Return values
Curl

setReturnHeader()

Set cURL option to return the header

public setReturnHeader([bool $header = true ]) : Curl
Parameters
$header : bool = true
Return values
Curl

setReturnTransfer()

Set cURL option to return the transfer

public setReturnTransfer([bool $transfer = true ]) : Curl
Parameters
$transfer : bool = true
Return values
Curl

throwError()

Throw an exception upon an error.

public throwError(string $error) : void
Parameters
$error : string
Tags
throws
Exception
Return values
void

version()

Return the cURL version

public version() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results