Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.41 KB | None | 0 0
  1. Déclaration REST :
  2.  
  3. $app->post('/res', \Core\Controllers\ResController::class . ':create');
  4.  
  5. Fonction qui récupère les arguments via $request
  6.  
  7. public function create(RequestInterface $request, ResponseInterface $response, $aArgs)
  8.     {
  9.         if (!empty($aArgs)) {
  10.             $aArgs = $aArgs;
  11.         } else {
  12.             $aArgs = $request->getQueryParams();
  13.             $aArgs['data'] = json_decode($aArgs['data']);
  14.             $aArgs['data'] = $this->object2array($aArgs['data']);
  15.         }
  16.  
  17.         $return = $this->storeResource($aArgs);
  18.  
  19.         if ($return['errors']) {
  20.             return $response
  21.                 ->withStatus(500)
  22.                 ->withJson(
  23.                     ['errors' => _NOT_CREATE . ' ' . $return['errors']]
  24.                 );
  25.         }
  26.  
  27.         return $response->withJson($return);
  28.     }
  29.  
  30. Script PHP pour reach le web service
  31.  
  32. <?php
  33.  
  34. /**
  35.  * This PestXML usage example pulls data from the OpenStreetMap API.
  36.  * (see http://wiki.openstreetmap.org/wiki/API_v0.6)
  37.  **/
  38.  
  39. require_once '../Pest.php';
  40.  
  41. $pest = new Pest('http://192.168.10.114/cs_maarch/');
  42.  
  43. $login = 'superadmin';
  44. $pass = 'superadmin';
  45. $pest->setupAuth($login,$pass);
  46.  
  47. $params = array(
  48.                         'encodedFile' => 'VEVTVA==',
  49.                         'data' => array(
  50.                                         array('column' => 'destination', 'value' => 'DGS', 'type' => 'string'),
  51.                                         array('column' => 'doc_date', 'value' => '2017-11-20 00:00:00', 'type' => 'string'),
  52.                                         array('column' => 'type_id', 'value' => '114', 'type' => 'string'),
  53.                                         array('column' => 'subject', 'value' => 'Sujet', 'type' => 'string'),
  54.                                         array('column' => 'custom_t14', 'value' => 'SVE', 'type' => 'string'),
  55.                                         array('column' => 'custom_t15', 'value' => 'nathan.cheval@outlook.fr', 'type' => 'string'),
  56.                                         array('column' => 'priority', 'value' => 3, 'type' => 'string'),
  57.                                   ),
  58.                         'collId' => 'letterbox_coll',
  59.                         'table' => 'res_letterbox',
  60.                         'fileFormat' => 'txt',
  61.                         'status' => 'ATTSVE'
  62.                 );
  63.  
  64. $test = $pest->post('/rest/res',$params);
  65. var_dump($test);
  66.  
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement