PHP Класс Bart\Curl

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

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

Метод Описание
__construct ( $hostUri, $port = 80 ) Curl to $hostUri on $port
delete ( $path, array $getParams, array $headers = null, null $cookies = null ) : array HTTP Delete Request
get ( string $path, array $getParams, array $headers = null, array $cookies = null ) : array
post ( string $path, array $getParams, string | array $postData, array $headers = null, string $cookies = null ) : array HTTP Post Request
put ( string $path, array $getParams, mixed $body = null, array $headers = null, string $cookies = null ) : array PUT a json body
setAuth ( string $user, string $pwd, integer $method = CURLAUTH_BASIC ) Set any authentication credentials desired for request(s)
setPhpCurlOpts ( array $curlOpts ) Fall back method to set your own curl options not currenctly explicitly support

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

Метод Описание
buildFullPath ( $subUri )
buildFullUri ( string $path, string[] $getVars ) : string build the full URI request
parseHeaders ( $headerString ) : array Parse the headers into an array that matches that pattern of http://php.net/manual/en/function.http-parse-headers.php
request ( $httpMethod, $path, array $getParams, $body, array $headers = null, $cookies = null )

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

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

Curl to $hostUri on $port
public __construct ( $hostUri, $port = 80 )

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

HTTP Delete Request
public delete ( $path, array $getParams, array $headers = null, null $cookies = null ) : array
$path
$getParams array
$headers array
$cookies null
Результат array

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

public get ( string $path, array $getParams, array $headers = null, array $cookies = null ) : array
$path string The resource path to be appended to the base URI
$getParams array key-value pairs
$headers array array of valid HTTP header strings; e.g. ['Accept: application/json']
$cookies array The contents of the "Cookie: " header to be used in the HTTP request. Note that multiple cookies are separated with a semicolon followed by a space
Результат array Response and info

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

HTTP Post Request
public post ( string $path, array $getParams, string | array $postData, array $headers = null, string $cookies = null ) : array
$path string relative path from base hostUri
$getParams array An associative array of get parameters
$postData string | array The data to send in your post
$headers array associative array of headers to include
$cookies string Cookies to include
Результат array Remote response body

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

PUT a json body
public put ( string $path, array $getParams, mixed $body = null, array $headers = null, string $cookies = null ) : array
$path string relative path from base hostUri
$getParams array An associative array of get parameters
$body mixed Optional array or string request body data to send
$headers array Optional headers to send with PUT
$cookies string Cookies to include
Результат array Remote response body

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

Set any authentication credentials desired for request(s)
public setAuth ( string $user, string $pwd, integer $method = CURLAUTH_BASIC )
$user string
$pwd string
$method integer (optional) Curl constant for the auth method type

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

Fall back method to set your own curl options not currenctly explicitly support
public setPhpCurlOpts ( array $curlOpts )
$curlOpts array An array specifying which options to set and their values. The keys must be valid curl_setopt() constants or their integer equivalents.