Skip to content

class ObjCurl

David Zurborg edited this page Aug 1, 2021 · 1 revision

src/Curl/ObjCurl.php


ObjCurl

Package

Application

Overview

Public Properties

No public properties found

Constants

DEFAULT_TIMEOUT() | FEATURES() | MIN_CURL_VERSION() | USER_AGENT() |

Public Methods

__construct() | accept() | basicAuth() | certificate() | ciphers() | contentType() | cookie() | cookies() | delete() | fakeResponse() | features() | form() | fragment() | get() | head() | header() | headers() | host() | insecure() | json() | mockResponse() | multiform() | patch() | path() | payload() | port() | post() | privateKey() | put() | queries() | query() | referer() | reset() | secure() | sslopt() | timeout() | url() | user() | version() | xml() |

Constants

DEFAULT_TIMEOUT

DEFAULT_TIMEOUT = 30

src/Curl/ObjCurl.php

FEATURES

FEATURES = ['ipv6', 'kerberos4', 'ssl', 'libz']

src/Curl/ObjCurl.php

MIN_CURL_VERSION

MIN_CURL_VERSION = 0 + 0x10000 * 7 + 0x100 * 22 + 0x1 * 0

src/Curl/ObjCurl.php

USER_AGENT

USER_AGENT = 'PHP ObjCurl/1.0 (+https://github.com/zurborg/libcurl-objcurl-php)'

src/Curl/ObjCurl.php

Methods

__construct()

Instanciates a new object

public __construct(string $url = 'http://localhost/') : mixed

accept()

Set Accept-header field

public accept(string $contentType) : self

basicAuth()

Set HTTP basic authentication

public basicAuth(string $username, ?string $password = null) : self

certificate()

Set SSL client certificate

public certificate(string $file, string $type = 'pem', ?string $pass = null) : self

ciphers()

Set SSL ciphers

$objcurl->ciphers(['RSA+AES', 'ECDHE+AES'])

* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `ciphers(string[]  $list) : self`


#### contentType()

Set Content-Type-header field

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `contentType(string  $contentType) : self`


#### cookie()

Set a single cookie

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `cookie(string  $key, string  $value) : self`


#### cookies()

Set multiple cookies at once

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `cookies(string[]  $cookies) : self`


**See also**
- [](classes/Curl-ObjCurl.html#method_cookie)
#### delete()

Submit request with DELETE method

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `delete() : \Curl\ObjCurl\Response`


#### fakeResponse()

Generate a fake response, bypassing response data directly

> This do not make an actual HTTP call and can be used in mock contexts
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `fakeResponse(int  $code = 200, array  $headers = [], string|null  $payload = null) : \Curl\ObjCurl\Response`


#### features()

Get a full list of supported cURL features

> The values in the array are either a version for example or just `true`.
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `features() : array`
`static` 

#### form()

Encode payload as application/x-www-form-urlencoded

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `form(string[]  $data) : self`


#### fragment()

Set path of URI

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `fragment(string  $fragment) : self`


#### get()

Submit request with GET method

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `get() : \Curl\ObjCurl\Response`


#### head()

Submit request with HEAD method

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `head() : \Curl\ObjCurl\Response`


#### header()

Set a single header field

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `header(string  $key, ?string  $value = null) : self`


#### headers()

Set multiple header fields

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `headers(string[]  $headers) : self`


**See also**
- [](classes/Curl-ObjCurl.html#method_header)
#### host()

Set host-part of URI

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `host(string  $host) : self`


#### insecure()

Do not use SSL

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `insecure() : self`


#### json()

Encode payload as JSON and set Accept- and Content-Type-headers accordingly

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `json(mixed  $data = null, string  $contentType = 'application/json') : self`


#### mockResponse()

Generate a fake response from scratch

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `mockResponse(string  $url, int  $code = 200, array  $headers = [], string|null  $payload = null) : \Curl\ObjCurl\Response`
`static` 

**See also**
- [](classes/Curl-ObjCurl.html#method_fakeResponse)
#### multiform()

Encode payload as multipart/form-data

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `multiform(string[]  $data) : self`


#### patch()

Submit request with PATCH method

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `patch() : \Curl\ObjCurl\Response`


#### path()

Set path of URI

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `path(string  $path) : self`


#### payload()

Set raw payload data

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `payload(array|object|string  $data) : self`


#### port()

Set port of URI

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `port(int  $port) : self`


#### post()

Submit request with POST method

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `post() : \Curl\ObjCurl\Response`


#### privateKey()

Set SSL private key

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `privateKey(string  $file, string  $type = 'pem', ?string  $pass = null) : self`


#### put()

Submit request with PUT method

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `put() : \Curl\ObjCurl\Response`


#### queries()

Set URL query param fields at once

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `queries(string[]  $params) : self`


#### query()

Set URL query param field

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `query(string  $key, ?string  $value = null) : self`


#### referer()

Set referer

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `referer(string  $referer) : self`


#### reset()

Reset every cURL-specific option except URL

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `reset() : self`


#### secure()

Use SSL (HTTPS)

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `secure() : self`


#### sslopt()

Set a SSL option

> Recognized boolean options:
+ `falsestart`
+ `enable_alpn`
+ `enable_npn`
+ `verifypeer`
+ `verifystatus`

Integer options:
+ `verifyhost`

String options:
+ `cipher_list` (but see also `ciphers` method below)
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `sslopt(string  $key, mixed  $val) : self`


#### timeout()

Set timeout in seconds

> If supported by cURL, fractional seconds are allowed. Otherwise the value will be truncated and interpreted as an integer
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `timeout(float  $seconds) : self`


#### url()

Set URL

> 
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `url(string  $url) : self`


#### user()

Set user-part of URI

> This is the @user part before the hostname of an URI
* Inherited from [\Curl\ObjCurl](class-ObjCurl)

`public` `user(string  $user) : self`


#### version()

Get some information about cURL

> ```php
$curl_version = ObjCurl::version();

public version(string $param = 'version', mixed $default = null) : mixed static

xml()

Encode paylod as XML and set Accept- and Content-Type-headers accordingly

public xml(?\DOMDocument $doc = null, string $contentType = 'application/xml') : self


\ » Classes » ObjCurl