Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Déclaration REST :
- $app->post('/res', \Core\Controllers\ResController::class . ':create');
- Fonction qui récupère les arguments via $request
- public function create(RequestInterface $request, ResponseInterface $response, $aArgs)
- {
- if (!empty($aArgs)) {
- $aArgs = $aArgs;
- } else {
- $aArgs = $request->getQueryParams();
- $aArgs['data'] = json_decode($aArgs['data']);
- $aArgs['data'] = $this->object2array($aArgs['data']);
- }
- $return = $this->storeResource($aArgs);
- if ($return['errors']) {
- return $response
- ->withStatus(500)
- ->withJson(
- ['errors' => _NOT_CREATE . ' ' . $return['errors']]
- );
- }
- return $response->withJson($return);
- }
- Script PHP pour reach le web service
- <?php
- /**
- * This PestXML usage example pulls data from the OpenStreetMap API.
- * (see http://wiki.openstreetmap.org/wiki/API_v0.6)
- **/
- require_once '../Pest.php';
- $pest = new Pest('http://192.168.10.114/cs_maarch/');
- $login = 'superadmin';
- $pass = 'superadmin';
- $pest->setupAuth($login,$pass);
- $params = array(
- 'encodedFile' => 'VEVTVA==',
- 'data' => array(
- array('column' => 'destination', 'value' => 'DGS', 'type' => 'string'),
- array('column' => 'doc_date', 'value' => '2017-11-20 00:00:00', 'type' => 'string'),
- array('column' => 'type_id', 'value' => '114', 'type' => 'string'),
- array('column' => 'subject', 'value' => 'Sujet', 'type' => 'string'),
- array('column' => 'custom_t14', 'value' => 'SVE', 'type' => 'string'),
- array('column' => 'custom_t15', 'value' => 'nathan.cheval@outlook.fr', 'type' => 'string'),
- array('column' => 'priority', 'value' => 3, 'type' => 'string'),
- ),
- 'collId' => 'letterbox_coll',
- 'table' => 'res_letterbox',
- 'fileFormat' => 'txt',
- 'status' => 'ATTSVE'
- );
- $test = $pest->post('/rest/res',$params);
- var_dump($test);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement