category OSS
package OSS_Countries
copyright Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland
license New BSD License

 Methods

Constructor

__construct(int $connectTimeOut, int $requestTimeOut, bool $returnTransfer, string $userName, string $password) : void

Parameters

$connectTimeOut

int

Connection time out, default is 3 seconds.

$requestTimeOut

int

Request time out, default is 5 seconds,

$returnTransfer

bool

$userName

string

User name if page url requires authorization

$password

string

Password if page url requires authorization

Closing curl object

close() : void

Sends a request to the the specified URL and returns with the response.

execute(string $pUrl, string | array | object | null $pData, string $pMethod, int $pResponseCode) : string | boolean

If $pData is not empty in a GET request, then it will be appended to the URL. In this case arrays are passed through http_build_query() first (so the values are urlencode()-ed), strings just simply appended to the URL. Append means the function will add the leading '?', too.

Parameters

$pUrl

string

$pData

stringarrayobjectnull

arrays values and object properties are automatically urlencode()-ed, otherwise you have to do it yourself if you pass a string

$pMethod

string

default self::HTTP_POST it can be HTTP_GET, HTTP_POST or HTTP_DELETE, any other value will be replaced by HTTP_POST; case insensitive

$pResponseCode

int

the HTTP response code is placed in this parameter

Returns

stringbooleana response string if $pReturnTransfer was true in init(), otherwise true on success or false on error

Gets error message

getError() : string

Returns

string

Gets response

getErrorCode() : string

Returns

string

Gets error message

getErrorMsg() : string

Returns

string

Gets method

getMethod() : string

Returns

string

Gets response

getResponse() : array

Returns

array

Gets URL

getUrl() : string

Returns

string

Represents an associative array ('key' => 'value', 'key' => 'value', .

httpBuildQuery(array $pArray, $pMode) : string
Static

..) in an RFC 1738 or 3986 format. It does what http_build_query() does, but http_build_query() only supports the older RFC 1738 format. New versions of PHP will support RFC 3986 natively, probably as of version 5.3.6 and 5.2.11. Check the online PHP documentation and your PHP version. By default this method is also using http_build_query() in RFC 1738 mode.

Parameters

$pArray

array

$pMode

Returns

string

Initialize cURL object

init(int $connectTimeOut, int $requestTimeOut, bool $returnTransfer, string $userName, string $password) : void

Parameters

$connectTimeOut

int

Connection time out, default is 3 seconds.

$requestTimeOut

int

Request time out, default is 5 seconds,

$returnTransfer

bool

$userName

string

User name if page url requires authorization

$password

string

Password if page url requires authorization

Set data

setData(array $data) : void

Please note that it overwrites (extends with data) the URL in GET requests.

Parameters

$data

array

Sets method

setMethod(string $method) : void

Parameters

$method

string

One of methods POST, GET, DELETE.

Set additional options for curl

setOption(string $option, mixed $value) : void

Parameters

$option

string

Option name

$value

mixed

Parameter value

Sets URL

setUrl(string $url) : void

Parameters

$url

string

Requests URL

 Properties

 

The cURL handler.

$_curlHandler : resource

We need a global variable to store the handle between cURL operations, so we can use persistent connections.

 

Curl method POST or GET

$_method : string
 

cURl response

$_response : array
 

URL for cURL

$_url : string

 Constants

 

HTTP_DELETE

HTTP_DELETE 
 

HTTP_GET

HTTP_GET 
 

HTTP_POST

HTTP_POST 
 

RFC_1738

RFC_1738 
 

RFC_3986

RFC_3986