vitalik74 / simple-request-json
Simple class implement request with JSON body.
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-10-26 18:11:48 UTC
README
REQUIREMENTS
The minimum requirement by this application template that your Web server supports PHP 5.4.0.
INSTALLATION
Install via Composer
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
You can then install this widget. Put in your composer.json in require case:
"vitalik74/simple-request-json": "*"
And run command "composer update".
USE
Data request run from Curl in default. If Curl not installed in system data request run from file_get_contents
function.
Example, how to use:
$response = (new Request(['url' => 'Url ', 'postData' => 'post data']))->getResponse();
Or
$response = new Request(['url' => 'Url ', 'postData' => 'post data']);
$response = $response->getResponse();
Or
$response = new Request();
$response->url = 'url';
$response->postData = 'post data';
$response->method = 'GET';// default in POST
$response = $response->getResponse();
Public property
$postData
- Post data to put in server.
$url
- Url from server.
$method
- POST or GET method.
$toArray
- Convert response from server to array with json_decode function
$noData
- If you no set data set this property to true
$sendToJsonFormat
- Send to server with json format (add special header)