Request
\nn\t3::Request()
Access to GET / POST variables, file containers etc.
Overview of Methods
\nn\t3::Request()->DELETE($url = '', $queryParams = [], $headers = []);
Sends a DELETE request (via curl) to a server
\nn\t3::Request()->DELETE( 'https://...', ['a'=>'123'] );
\nn\t3::Request()->DELETE( 'https://...', ['a'=>'123'], ['Accept-Encoding'=>'gzip, deflate'] );
@param string $url
@param array $queryParams
@param array $headers
@return array
\nn\t3::Request()->GET($url = '', $queryParams = [], $headers = [], $dontNestArrays = false);
Sends a GET request (via curl) to a server
\nn\t3::Request()->GET( 'https://...', ['a'=>'123'] );
\nn\t3::Request()->GET( 'https://...', ['a'=>'123'], ['Accept-Encoding'=>'gzip, deflate'] );
// if 'a'=>[1,2,3] should be sent as a=1&a=2&a=3 instead of a[]=1&a[]=2&a[]=3
\nn\t3::Request()->GET( 'https://...', ['a'=>[1,2,3]], [], true );
@param string $url
@param array $queryParams
@param array $headers
@return array
\nn\t3::Request()->GET_JSON($url = '', $queryParams = [], $headers = NULL);
Sends a GET request to a server and parses the result as JSON
\nn\t3::Request()->GET_JSON( 'https://...', ['a'=>'123'] );
@param string $url
@param array $queryParams
@param array $headers
@return array
\nn\t3::Request()->GP($varName = NULL);
Merge from $_GET and $_POST variables
\nn\t3::Request()->GP();
| @return array
\nn\t3::Request()->JSON($url = '', $data = [], $headers = NULL);
Sends a JSON to a server via POST
\nn\t3::Request()->JSON( 'https://...', ['a'=>'123'] );
@param string $url
@param array $data
@param array|null $headers
@return array
\nn\t3::Request()->POST($url = '', $postData = [], $headers = [], $requestType = 'POST');
Sends a POST request (via CURL) to a server.
\nn\t3::Request()->POST( 'https://...', ['a'=>'123'] );
\nn\t3::Request()->POST( 'https://...', ['a'=>'123'], ['Accept-Encoding'=>'gzip, deflate'] );
@param string $url
@param array $postData
@param array $headers
@return array
\nn\t3::Request()->PUT($url = '', $data = [], $headers = []);
Sends a PUT request (via curl) to a server
\nn\t3::Request()->PUT( 'https://...', ['a'=>'123'] );
\nn\t3::Request()->PUT( 'https://...', ['a'=>'123'], ['Accept-Encoding'=>'gzip, deflate'] );
@param string $url
@param array $data
@param array $headers
@return array
\nn\t3::Request()->PUT_JSON($url = '', $data = [], $headers = []);
Sends a PUT request (via curl) to a server as JSON
\nn\t3::Request()->PUT_JSON( 'https://...', ['a'=>'123'] );
\nn\t3::Request()->PUT_JSON( 'https://...', ['a'=>'123'], ['Accept-Encoding'=>'gzip, deflate'] );
@param string $url
@param array $data
@param array $headers
@return array
\nn\t3::Request()->files($path = NULL, $forceArray = false);
Get and normalize file uploads from $_FILES.
Normalizes the following file upload variants. Removes empty file uploads from the array.
- Examples:
GetALL file info from$_FILES.
\nn\t3::Request()->files();
\nn\t3::Request()->files( true ); // Force array
Get file info from tx_nnfesubmit_nnfesubmit[...].
\nn\t3::Request()->files('tx_nnfesubmit_nnfesubmit');
\nn\t3::Request()->files('tx_nnfesubmit_nnfesubmit', true); // Force array
Only get files from tx_nnfesubmit_nnfesubmit[fal_media].
\nn\t3::Request()->files('tx_nnfesubmit_nnfesubmit.fal_media' );
\nn\t3::Request()->files('tx_nnfesubmit_nnfesubmit.fal_media', true ); // Force array
| @return array
\nn\t3::Request()->getAuthorizationHeader();
Read the Authorization header from the request.
\nn\t3::Request()->getAuthorizationHeader();
Important: If this does not work, the following line is probably missing in the .htaccess is probably missing the following line:
# nnhelpers: Use when PHP is executed in PHP CGI mode
RewriteRule . - E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
| @return string
\nn\t3::Request()->getBasicAuth();
Read the Basic Authorization Header from the request. If available, the username and password are returned.
$credentials = \nn\t3::Request()->getBasicAuth(); // ['username'=>'...', 'password'=>'...']
Example call from a test script:
echo file_get_contents('https://username:password@www.testsite.com');
| @return array
\nn\t3::Request()->getBearerToken();
Read the bearer header
Is used, among other things, to transmit a JWT (Json Web Token).
\nn\t3::Request()->getBearerToken();
| @return string|null
\nn\t3::Request()->getJwt();
Read the JWT (Json Web Token) from the request, validate it and, if the signature is successfully check the signature and return the payload of the JWT.
\nn\t3::Request()->getJwt();
| @return array|string
\nn\t3::Request()->getUri($varName = NULL);
Return the request URI. Basically the URL / the GET string
in the browser URL bar, which is stored in $_SERVER['REQUEST_URI']
is saved.
\nn\t3::Request()->getUri();
| @return string
\nn\t3::Request()->mergeGetParams($url = '', $getParams = [], $dontNestArrays = false);
@param string $url
@param array $getParams
@param bool $dontNestArrays
@return string