mckaygerhard
bd5afb5078
* separation of "notFound" module into one for api and one for Views if there is a wrong url will show `notFoundApi` module results otherwise will show the borrow of `notFound` * provide new module for storage, under `api/v1/store` route, it receives 3 arguments, will check nature of variables and store if those are valid, the API will store a tree CTE data! * provide enhanced listing under `api/v1/lists` route, that optionally receives one argument, if present will try to retrieve it data with filtering, otherwise will retreive all * documents te layer oif the database used on the example, cos is a CTE recursive emulated layer table. * documents into `DEVEL.md` the separate development from quick deploy * tune up the `.env` file, only use minimal variables, remove non usefully * use 0 spaces into the editors for the init config files on `.editorconfig` * by defaults use sqlite3 databe in config file * privide minimal test using php code
79 lines
1.7 KiB
PHP
79 lines
1.7 KiB
PHP
<?php
|
|
|
|
$env = parse_ini_file('../.env');
|
|
|
|
|
|
|
|
|
|
/* *** send as json SAVE DATA ************************************************* */
|
|
|
|
$url = $env["APP_HOST"].':'.$env["APP_PORT"]."/api/v1/store";
|
|
|
|
// Create a new cURL resource
|
|
$ch = curl_init($url);
|
|
|
|
// Setup request to send json via POST
|
|
$data = array(
|
|
'PAL' => 'PUV',
|
|
'cedh' => '1234565',
|
|
'cedp' => '1234567'
|
|
);
|
|
|
|
$payload = json_encode(array("user" => $data));
|
|
|
|
// Attach encoded JSON string to the POST fields
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
|
|
|
// Set the content type to application/json
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
|
|
|
// Return response instead of outputting
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
// Execute the POST request
|
|
$result = curl_exec($ch);
|
|
|
|
// Close cURL resource
|
|
curl_close($ch);
|
|
|
|
var_dump($result);
|
|
/* *** end send as json ************************************************* */
|
|
|
|
|
|
|
|
|
|
/* *** send as post SAVE DATA ************************************************* */
|
|
|
|
$url = $env["APP_HOST"].':'.$env["APP_PORT"]."/api/v1/store";
|
|
|
|
// Create a new cURL resource
|
|
$ch = curl_init($url);
|
|
|
|
// Setup request to send json via POST
|
|
$fields = array(
|
|
'PAL' => 'PUV',
|
|
'cedh' => '1234565',
|
|
'cedp' => '1234567'
|
|
);
|
|
|
|
$payload = http_build_query($data);
|
|
|
|
// Attach encoded fields string to the POST url
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
|
|
|
// Set the content type to http post
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
|
|
// Return response instead of outputting
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
// Execute the POST request
|
|
$result = curl_exec($ch);
|
|
|
|
// Close cURL resource
|
|
curl_close($ch);
|
|
|
|
var_dump($result);
|
|
/* *** end send as post ************************************************* */
|
|
|