Mock brickfield connect.
More...
|
| cleanopt () |
| Reset http method.
|
|
| delete ($url, $param=array(), $options=array()) |
| HTTP DELETE method.
|
|
| download ($requests, $options=array()) |
| Download multiple files in parallel.
|
|
| download_one ($url, $params, $options=array()) |
| Downloads one file and writes it to the specified file handler.
|
|
| get ($url, $params=array(), $options=array()) |
| HTTP GET method.
|
|
| get_errno () |
| Get curl error code.
|
|
| get_info () |
| Get curl information.
|
|
| get_raw_response () |
| Get raw HTTP Response Headers.
|
|
| get_security () |
| Returns the current curl security helper.
|
|
| getResponse () |
| Get HTTP Response Headers.
|
|
| head ($url, $options=array()) |
| HTTP HEAD method.
|
|
| is_registered () |
| Is registered.
|
|
| options ($url, $options=array()) |
| HTTP OPTIONS method.
|
|
| patch ($url, $params='', $options=array()) |
| HTTP PATCH method.
|
|
| post ($url, $params='', $options=array()) |
| HTTP POST method.
|
|
| put ($url, $params=array(), $options=array()) |
| HTTP PUT method.
|
|
| resetcookie () |
| Reset Cookie.
|
|
| resetHeader () |
| Resets the HTTP Request headers (to prepare for the new request)
|
|
| resetopt () |
| Resets the CURL options that have already been set.
|
|
| send_summary () |
| Send the summary data to Brickfield.
|
|
| set_security ($securityobject) |
| Sets the curl security helper.
|
|
| setHeader ($header) |
| Set HTTP Request Header.
|
|
| setopt ($options=array()) |
| Set curl options.
|
|
| trace ($url, $options=array()) |
| HTTP TRACE method.
|
|
| update_registration (string $apikey, string $secretkey) |
| Update Registration.
|
|
|
static | get_cacert () |
| Get the location of ca certificates.
|
|
static | mock_response ($response) |
| For use only in unit tests - we can pre-set the next curl response.
|
|
static | strip_double_headers ($input) |
| When using a proxy, an additional HTTP response code may appear at the start of the header.
|
|
|
array | $_tmp_file_post_params = [] |
| temporary params value if the value is not belongs to class stored_file.
|
|
curl_cache false | $cache = false |
| Caches http request contents.
|
|
bool | $emulateredirects = null |
| Perform redirects at PHP level instead of relying on native cURL functionality.
|
|
int | $errno |
| error code
|
|
string | $error |
| error
|
|
array | $header = array() |
| http header
|
|
array | $info |
| cURL information
|
|
bool | $proxy = null |
| Uses proxy, null means automatic based on URL.
|
|
array | $rawresponse = array() |
| Raw response headers, needed for BC in download_file_content().
|
|
array | $response = array() |
| http's response
|
|
string | $version = '0.4 dev' |
| library version
|
|
array const | ACTION_CHECK_REGISTRATION |
| Endpoint details for setting and checking a site registration.
|
|
array const | ACTION_SEND_SUMMARY |
| Endpoint details for sending site summary data.
|
|
const | VALIDAPIKEY = '123456789012345678901234567890ab' |
| Valid api key.
|
|
const | VALIDSECRETKEY = 'ab123456789012345678901234567890' |
| Valid secret key.
|
|
|
string | $apikey = '' |
| api key.
|
|
string | $secretkey = '' |
| Secret key.
|
|
◆ call()
tool_brickfield\brickfieldconnect::call |
( |
array | $command, |
|
|
| $params = '' ) |
|
protectedinherited |
Call the specified command.
- Parameters
-
array | $command | The command to call, for example see self\ACTION_REGISTER |
array | string | $params | The params provided to the call |
- Return values
-
◆ check_securityhelper_blocklist()
curl::check_securityhelper_blocklist |
( |
string | $url | ) |
|
|
protectedinherited |
check_securityhelper_blocklist.
Checks whether the given URL is blocked by checking both plugin's security helpers and core curl security helper or any curl security helper that passed to curl class constructor. If ignoresecurity is set to true, skip checking and consider the url is not blocked. This augments all installed plugin's security helpers if there is any.
- Parameters
-
string | $url | the url to check. |
- Return values
-
?string | - an error message if URL is blocked or null if URL is not blocked. |
◆ delete()
curl::delete |
( |
| $url, |
|
|
| $param = array(), |
|
|
| $options = array() ) |
|
inherited |
HTTP DELETE method.
- Parameters
-
string | $url | |
array | $param | |
array | $options | |
- Return values
-
◆ download()
curl::download |
( |
| $requests, |
|
|
| $options = array() ) |
|
inherited |
Download multiple files in parallel.
Calls multi() with specific download headers
$c = new curl(); $file1 = fopen('a', 'wb'); $file2 = fopen('b', 'wb'); $c->download(array( array('url'=>'http://localhost/', 'file'=>$file1), array('url'=>'http://localhost/20/', 'file'=>$file2) )); fclose($file1); fclose($file2);
or
$c = new curl(); $c->download(array( array('url'=>'http://localhost/', 'filepath'=>'/tmp/file1.tmp'), array('url'=>'http://localhost/20/', 'filepath'=>'/tmp/file2.tmp') ));
- Parameters
-
array | $requests | An array of files to request { url => url to download the file [required] file => file handler, or filepath => file path } If 'file' and 'filepath' parameters are both specified in one request, the open file handle in the 'file' parameter will take precedence and 'filepath' will be ignored. |
array | $options | An array of options to set |
- Return values
-
◆ download_one()
curl::download_one |
( |
| $url, |
|
|
| $params, |
|
|
| $options = array() ) |
|
inherited |
Downloads one file and writes it to the specified file handler.
$c = new curl(); $file = fopen('savepath', 'w'); $result = $c->download_one('http://localhost/', null, array('file' => $file, 'timeout' => 5, 'followlocation' => true, 'maxredirs' => 3)); fclose($file); $download_info = $c->get_info(); if ($result === true) { // file downloaded successfully } else { $error_text = $result; $error_code = $c->get_errno(); }
$c = new curl(); $result = $c->download_one('http://localhost/', null, array('filepath' => 'savepath', 'timeout' => 5, 'followlocation' => true, 'maxredirs' => 3)); // ... see above, no need to close handle and remove file if unsuccessful
- Parameters
-
string | $url | |
array | null | $params | key-value pairs to be added to $url as query string |
array | $options | request options. Must include either 'file' or 'filepath' |
- Return values
-
bool|string | true on success or error string on failure |
◆ get()
curl::get |
( |
| $url, |
|
|
| $params = array(), |
|
|
| $options = array() ) |
|
inherited |
HTTP GET method.
- Parameters
-
string | $url | |
?array | $params | |
array | $options | |
- Return values
-
◆ get_baseapiuri()
tool_brickfield\brickfieldconnect::get_baseapiuri |
( |
| ) |
|
|
protectedinherited |
Get the check registration API URI.
- Return values
-
◆ get_cacert()
static curl::get_cacert |
( |
| ) |
|
|
staticinherited |
Get the location of ca certificates.
- Return values
-
string | absolute file path or empty if default used |
◆ get_common_headers()
tool_brickfield\brickfieldconnect::get_common_headers |
( |
| ) |
|
|
protectedinherited |
Get the common headers used for all calls to the Brickfields endpoints.
- Return values
-
◆ get_errno()
Get curl error code.
- Return values
-
◆ get_info()
Get curl information.
- Return values
-
◆ get_raw_response()
curl::get_raw_response |
( |
| ) |
|
|
inherited |
Get raw HTTP Response Headers.
- Return values
-
◆ get_registration_id_for_credentials()
tool_brickfield\brickfieldconnect::get_registration_id_for_credentials |
( |
string | $apikey = null, |
|
|
string | $secretkey = null ) |
|
protectedinherited |
Get the registration ID for the given set of credentials.
- Parameters
-
null | string | $apikey | The API key to use for the registration attempt |
null | string | $secretkey | The secret key to use |
- Return values
-
null|string | The registration ID if registration was successful, or null if not |
◆ get_security()
Returns the current curl security helper.
- Return values
-
◆ get_siteurl()
tool_brickfield\brickfieldconnect::get_siteurl |
( |
| ) |
|
|
protectedinherited |
Get a normalised URL for the site.
- Return values
-
◆ get_url_for_command()
tool_brickfield\brickfieldconnect::get_url_for_command |
( |
array | $command | ) |
|
|
protectedinherited |
Get the URL required for the command.
- Parameters
-
array | $command | The command to call, for example see self\ACTION_REGISTER |
- Return values
-
◆ getResponse()
Get HTTP Response Headers.
- Return values
-
◆ has_registration_key()
tool_brickfield\brickfieldconnect::has_registration_key |
( |
| ) |
|
|
protectedinherited |
Whether the site currently has a registration key stored.
- Return values
-
◆ head()
curl::head |
( |
| $url, |
|
|
| $options = array() ) |
|
inherited |
HTTP HEAD method.
- See also
- request()
- Parameters
-
- Return values
-
◆ is_registered()
tool_brickfield\mock_brickfieldconnect::is_registered |
( |
| ) |
|
◆ mock_response()
static curl::mock_response |
( |
| $response | ) |
|
|
staticinherited |
For use only in unit tests - we can pre-set the next curl response.
This is useful for unit testing APIs that call external systems.
- Parameters
-
◆ multi()
curl::multi |
( |
| $requests, |
|
|
| $options = array() ) |
|
protectedinherited |
Multi HTTP Requests This function could run multi-requests in parallel.
- Parameters
-
array | $requests | An array of files to request |
array | $options | An array of options to set |
- Return values
-
Reimplemented in oauth2_client.
◆ options()
curl::options |
( |
| $url, |
|
|
| $options = array() ) |
|
inherited |
HTTP OPTIONS method.
- Parameters
-
- Return values
-
◆ patch()
curl::patch |
( |
| $url, |
|
|
| $params = '', |
|
|
| $options = array() ) |
|
inherited |
HTTP PATCH method.
- Parameters
-
string | $url | |
array | string | $params | |
array | $options | |
- Return values
-
◆ post()
curl::post |
( |
| $url, |
|
|
| $params = '', |
|
|
| $options = array() ) |
|
inherited |
HTTP POST method.
- Parameters
-
string | $url | |
array | string | $params | |
array | $options | |
- Return values
-
◆ put()
curl::put |
( |
| $url, |
|
|
| $params = array(), |
|
|
| $options = array() ) |
|
inherited |
HTTP PUT method.
- Parameters
-
string | $url | |
array | $params | |
array | $options | |
- Return values
-
◆ request()
curl::request |
( |
| $url, |
|
|
| $options = array() ) |
|
protectedinherited |
Single HTTP Request.
- Parameters
-
string | $url | The URL to request |
array | $options | |
- Return values
-
◆ reset_request_state_vars()
curl::reset_request_state_vars |
( |
| ) |
|
|
protectedinherited |
Helper function to reset the request state vars.
- Return values
-
◆ send_summary()
tool_brickfield\brickfieldconnect::send_summary |
( |
| ) |
|
|
inherited |
Send the summary data to Brickfield.
- Return values
-
- Exceptions
-
◆ set_headers()
tool_brickfield\brickfieldconnect::set_headers |
( |
array | $headers | ) |
|
|
protectedinherited |
Set headers on the request from the specified list of headers.
- Parameters
-
array | $headers | An array of header name => value |
◆ set_security()
curl::set_security |
( |
| $securityobject | ) |
|
|
inherited |
Sets the curl security helper.
- Parameters
-
- Return values
-
bool | true if the security helper could be set, false otherwise. |
◆ setHeader()
curl::setHeader |
( |
| $header | ) |
|
|
inherited |
Set HTTP Request Header.
- Parameters
-
◆ setopt()
curl::setopt |
( |
| $options = array() | ) |
|
|
inherited |
Set curl options.
Do not use the curl constants to define the options, pass a string corresponding to that constant. Ie. to set CURLOPT_MAXREDIRS, pass array('CURLOPT_MAXREDIRS' => 10) or array('maxredirs' => 10) to this method.
- Parameters
-
array | $options | If array is null, this function will reset the options to default value. |
- Return values
-
- Exceptions
-
◆ strip_double_headers()
static curl::strip_double_headers |
( |
| $input | ) |
|
|
staticinherited |
When using a proxy, an additional HTTP response code may appear at the start of the header.
For example, when using https over a proxy there may be 'HTTP/1.0 200 Connection Established'. Other codes are also possible and some may come with their own headers.
If using the return value containing all headers, this function can be called to remove unwanted doubles.
Note that it is not possible to distinguish this situation from valid data unless you know the actual response part (below the headers) will not be included in this string, or else will not 'look like' HTTP headers. As a result it is not safe to call this function for general data.
- Parameters
-
string | $input | Input HTTP response |
- Return values
-
string | HTTP response with additional headers stripped if any |
◆ trace()
curl::trace |
( |
| $url, |
|
|
| $options = array() ) |
|
inherited |
HTTP TRACE method.
- Parameters
-
- Return values
-
◆ update_registration()
tool_brickfield\mock_brickfieldconnect::update_registration |
( |
string | $apikey, |
|
|
string | $secretkey ) |
◆ $emulateredirects
bool curl::$emulateredirects = null |
|
inherited |
Perform redirects at PHP level instead of relying on native cURL functionality.
Always true now.
◆ ACTION_CHECK_REGISTRATION
array const tool_brickfield\brickfieldconnect::ACTION_CHECK_REGISTRATION |
|
inherited |
Initial value:= [
'endpoint' => 'checkRegister',
'method' => 'get',
]
Endpoint details for setting and checking a site registration.
◆ ACTION_SEND_SUMMARY
array const tool_brickfield\brickfieldconnect::ACTION_SEND_SUMMARY |
|
inherited |
Initial value:= [
'endpoint' => 'summary',
'method' => 'post',
]
Endpoint details for sending site summary data.
The documentation for this class was generated from the following file:
- admin/tool/brickfield/tests/generator/mock_brickfieldconnect.php