CoreRequest
in package
$this->core->request Object is used to handle http requests
Table of Contents
Properties
Methods
- addError() : mixed
- call() : bool|false|string
- Allow to execute a GET,POST,PUT,PATCH,DELETE call with variables and files All the calls will try to add the following headers if they exit in $this->core->config: - X-CLOUDFRAMEWORK-SECURITY - X-SERVER-KEY - X-DS-TOKEN - X-EXTRA-INFO
- defaultServiceUrl() : string
- delete() : bool|string
- DELETE
- delete_json_decode() : array<string|int, bool>|mixed|array<string|int, string>
- DELETE
- generateCloudFrameWorkSecurityString() : string|null
- Generate a CloudFrameWork SecurityS tring to be used with a API with CloudFramework Technology
- get() : bool|string
- GET
- get_json_decode() : array<string|int, bool>|mixed|array<string|int, string>
- GET CALL expecting a json response
- getCache() : mixed
- Call External Cloud Service Caching the result
- getCurl() : false|string
- CURL METHOD
- getHeader() : mixed|string
- Returns a specific Header received in a API call
- getHeaders() : array<string|int, mixed>
- Return all headers received in a API call
- getLastResponseCode() : mixed
- getResponseHeader() : mixed
- getServiceUrl() : mixed
- getUrlHeader() : string|array<string|int, mixed>
- getUrlHeaders() : array<string|int, mixed>
- patch() : bool|string
- patch_json_decode() : array<string|int, bool>|mixed|array<string|int, string>
- PATCH
- post() : bool|string
- POST
- post_json_decode() : array<string|int, bool>|mixed|array<string|int, string>
- POST CALL expecting a json response
- put() : bool|string
- PUT
- put_json_decode() : array<string|int, bool>|mixed|array<string|int, string>
- PUT CALL expecting a json response
- reset() : mixed
- Reset $this->errorMsg and $this->error vars
- sendCorsHeaders() : mixed
- Send Cors headers to allow AJAX calls
- sendLog() : mixed
- urlExists() : bool
- Check if the URL passed exists
- processResponseHeaders() : mixed
Properties
$error
public
bool
$error
= \false
it allow to know if the last call has returned an error. $this->core->request->error
$errorMsg
public
array<string|int, mixed>
$errorMsg
= []
It contains the last errors. $this->core->request->errorMsg
Methods
addError()
public
addError(mixed $value) : mixed
Parameters
- $value : mixed
call()
Allow to execute a GET,POST,PUT,PATCH,DELETE call with variables and files All the calls will try to add the following headers if they exit in $this->core->config: - X-CLOUDFRAMEWORK-SECURITY - X-SERVER-KEY - X-DS-TOKEN - X-EXTRA-INFO
public
call( $route[, null $data = null ][, string $verb = 'GET' ][, null $extra_headers = null ][, bool $raw = false ]) : bool|false|string
Sending files: If you need to send files it can only be made with POST/PUT and $raw=false $data has to include $data['__files'] = array($file,$file,..) where $file = [ 'file_content'=>'{content to send}' // if file_path is not sent this is mandatory. Content of file ,'file_path'=>'{path_to_content}' // if file_content is not sent this is mandatory. Path of the file content ,'file_name'=>'{name_of_file}' // Name of file ,'file_type'=>'{file type}' // Content-Type of the file. Example: application/pdf ,'file_var'=>'{name_of_var}' // Optional var name to be used sending the file. You can use {name_of_var}[] for multiple files in the same var. default = file
Sending JSON data: Put $raw = true;
Extra info: https://stackoverflow.com/questions/4003989/upload-a-file-using-file-get-contents For extra headers you can get further information in: https://www.php.net/manual/de/context.http.php
Parameters
- $route :
- $data : null = null
- $verb : string = 'GET'
- $extra_headers : null = null
- $raw : bool = false
Return values
bool|false|stringdefaultServiceUrl()
public
defaultServiceUrl([string $path = '' ]) : string
Parameters
- $path : string = ''
-
Path to complete URL. if it does no start with http.. $path will be aggregated to: $this->core->config->get("CloudServiceUrl")
Return values
stringdelete()
DELETE
public
delete( $route[, null $extra_headers = null ][, null $data = null ][, false $send_in_json = false ]) : bool|string
Parameters
Return values
bool|stringdelete_json_decode()
DELETE
public
delete_json_decode( $route[, null $extra_headers = null ][, null $data = null ][, false $send_in_json = false ]) : array<string|int, bool>|mixed|array<string|int, string>
Parameters
Return values
array<string|int, bool>|mixed|array<string|int, string>generateCloudFrameWorkSecurityString()
Generate a CloudFrameWork SecurityS tring to be used with a API with CloudFramework Technology
public
generateCloudFrameWorkSecurityString( $id[, string $time = '' ][, string $secret = '' ]) : string|null
Parameters
Tags
Return values
string|nullget()
GET
public
get( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : bool|string
Parameters
Return values
bool|stringget_json_decode()
GET CALL expecting a json response
public
get_json_decode( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : array<string|int, bool>|mixed|array<string|int, string>
Parameters
Return values
array<string|int, bool>|mixed|array<string|int, string>getCache()
Call External Cloud Service Caching the result
public
getCache(mixed $route[, mixed $data = null ][, mixed $verb = 'GET' ][, mixed $extraheaders = null ][, mixed $raw = false ]) : mixed
Parameters
- $route : mixed
- $data : mixed = null
- $verb : mixed = 'GET'
- $extraheaders : mixed = null
- $raw : mixed = false
getCurl()
CURL METHOD
public
getCurl( $route[, null $data = null ][, string $verb = 'GET' ][, null $extra_headers = null ][, false $raw = false ]) : false|string
Parameters
- $route :
- $data : null = null
- $verb : string = 'GET'
- $extra_headers : null = null
- $raw : false = false
Tags
Return values
false|stringgetHeader()
Returns a specific Header received in a API call
public
getHeader( $str) : mixed|string
Parameters
Return values
mixed|stringgetHeaders()
Return all headers received in a API call
public
getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>getLastResponseCode()
public
getLastResponseCode() : mixed
getResponseHeader()
public
getResponseHeader(mixed $key) : mixed
Parameters
- $key : mixed
getServiceUrl()
public
getServiceUrl([mixed $path = '' ]) : mixed
Parameters
- $path : mixed = ''
getUrlHeader()
public
getUrlHeader( $url[, $header = null ]) : string|array<string|int, mixed>
Parameters
Return values
string|array<string|int, mixed>getUrlHeaders()
public
getUrlHeaders(string $url) : array<string|int, mixed>
Parameters
- $url : string
Tags
Return values
array<string|int, mixed>patch()
public
patch( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : bool|string
Parameters
Return values
bool|stringpatch_json_decode()
PATCH
public
patch_json_decode( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : array<string|int, bool>|mixed|array<string|int, string>
Parameters
Return values
array<string|int, bool>|mixed|array<string|int, string>post()
POST
public
post( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : bool|string
Parameters
Return values
bool|stringpost_json_decode()
POST CALL expecting a json response
public
post_json_decode( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : array<string|int, bool>|mixed|array<string|int, string>
Parameters
Return values
array<string|int, bool>|mixed|array<string|int, string>put()
PUT
public
put( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : bool|string
Parameters
Return values
bool|stringput_json_decode()
PUT CALL expecting a json response
public
put_json_decode( $route[, null $data = null ][, null $extra_headers = null ][, false $send_in_json = false ]) : array<string|int, bool>|mixed|array<string|int, string>
Parameters
Return values
array<string|int, bool>|mixed|array<string|int, string>reset()
Reset $this->errorMsg and $this->error vars
public
reset() : mixed
sendCorsHeaders()
Send Cors headers to allow AJAX calls
public
sendCorsHeaders([string $methods = 'GET,POST,PUT' ][, string $origin = '' ][, string $extra_headers = '' ]) : mixed
Parameters
- $methods : string = 'GET,POST,PUT'
- $origin : string = ''
- $extra_headers : string = ''
sendLog()
public
sendLog(mixed $type, mixed $cat, mixed $subcat, mixed $title[, mixed $text = '' ][, mixed $email = '' ][, mixed $app = '' ][, mixed $interactive = false ]) : mixed
Parameters
- $type : mixed
- $cat : mixed
- $subcat : mixed
- $title : mixed
- $text : mixed = ''
- $email : mixed = ''
- $app : mixed = ''
- $interactive : mixed = false
urlExists()
Check if the URL passed exists
public
urlExists(string $url) : bool
Parameters
- $url : string
Return values
boolprocessResponseHeaders()
private
processResponseHeaders() : mixed