当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getBody方法代码示例

本文整理汇总了PHP中Slim\Http\Request::getBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBody方法的具体用法?PHP Request::getBody怎么用?PHP Request::getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Request的用法示例。


在下文中一共展示了Request::getBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBody

 public function getBody()
 {
     $body = $this->request->getBody();
     if ($body == '') {
         return array();
     }
     return json_decode($body, true);
 }
开发者ID:QualityUnit,项目名称:swagger-codegen,代码行数:8,代码来源:Params.class.php

示例2: buildParams

 private function buildParams(array $params = array())
 {
     $body = $this->request->getBody();
     if (is_array($body) === false) {
         $body = array();
     }
     if (array_key_exists(0, $body) === true) {
         $body = array(self::PARAM_REQUEST_BODY => $body);
     }
     return array_replace($this->request->params(), $body, $params);
 }
开发者ID:benconnito,项目名称:kopper,代码行数:11,代码来源:Controller.php

示例3: getPayload

 public function getPayload()
 {
     $payload = json_decode($this->request->getBody(), true);
     $exception = null;
     switch (json_last_error()) {
         case JSON_ERROR_NONE:
             break;
         case JSON_ERROR_DEPTH:
             $exception = 'Maximum stack depth exceeded';
             break;
         case JSON_ERROR_STATE_MISMATCH:
             $exception = 'Underflow or the modes mismatch';
             break;
         case JSON_ERROR_CTRL_CHAR:
             $exception = 'Unexpected control character found';
             break;
         case JSON_ERROR_SYNTAX:
             $exception = 'Syntax error, malformed JSON';
             break;
         case JSON_ERROR_UTF8:
             $exception = 'Malformed UTF-8 characters, possibly incorrectly encoded';
             break;
         default:
             $exception = 'Unknown error';
             break;
     }
     if ($exception) {
         throw new \Exception('Error decoding payload: ' . $exception);
     }
     return $payload;
 }
开发者ID:dwsla,项目名称:deal,代码行数:31,代码来源:BaseController.php

示例4: __invoke

 /**
  * Execute the middleware.
  *
  * @param  \Slim\Http\Request  $req
  * @param  \Slim\Http\Response $res
  * @param  callable            $next
  * @return \Slim\Http\Response
  */
 public function __invoke(Request $req, Response $res, callable $next)
 {
     $uri = $req->getUri();
     $path = $this->filterTrailingSlash($uri);
     if ($uri->getPath() !== $path) {
         return $res->withStatus(301)->withHeader('Location', $path)->withBody($req->getBody());
     }
     //        if ($this->filterBaseurl($uri)) {
     //            return $res->withStatus(301)
     //                ->withHeader('Location', (string) $uri)
     //                ->withBody($req->getBody());
     //        }
     $server = $req->getServerParams();
     if (!isset($server['REQUEST_TIME_FLOAT'])) {
         $server['REQUEST_TIME_FLOAT'] = microtime(true);
     }
     $uri = $uri->withPath($path);
     $req = $this->filterRequestMethod($req->withUri($uri));
     $res = $next($req, $res);
     $res = $this->filterPrivateRoutes($uri, $res);
     // Only provide response calculation time in non-production env, tho.
     if ($this->settings['mode'] !== 'production') {
         $time = (microtime(true) - $server['REQUEST_TIME_FLOAT']) * 1000;
         $res = $res->withHeader('X-Response-Time', sprintf('%2.3fms', $time));
     }
     return $res;
 }
开发者ID:ninjanero,项目名称:slim-skeleton,代码行数:35,代码来源:CommonMiddleware.php

示例5: borrartipoturnosucursal

 function borrartipoturnosucursal(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $id = $request->getAttribute("id");
     $tipo = Tipoturnosucursal::select("*")->where("idsucursal", "=", $id)->delete();
     $response->getBody()->write($tipo);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:TipoturnosucursalControl.php

示例6: eliminarservicios

 function eliminarservicios(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $id = $request->getAttribute("idempleado");
     $tipo = ServiciosEmpleado::select("*")->where("idEmpleado", "=", $id)->delete();
     $response->getBody()->write($tipo);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:9,代码来源:ServiciosEmpleadoControl.php

示例7: promocionesByCategorias

 function promocionesByCategorias(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $data = Promocion::select("promocion.*")->join("categoriaspromocion", "categoriaspromocion.idPromocion", "=", "promocion.id")->whereIn("categoriaspromocion.idCategoria", $data['categorias'])->distinct()->get();
     if (count($data) == 0) {
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($data);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:11,代码来源:PromocionControl.php

示例8: putIdPushByUsuario

 function putIdPushByUsuario(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $id = $request->getAttribute('id');
     $data = json_decode($request->getBody(), true);
     try {
         $usuario = Usuario::where('id', '=', $id)->first();
         $usuario->idPush = $data['idPush'];
         $usuario->save();
         $respuesta = json_encode(array('msg' => "Modificado correctamente", "std" => 1, "obj" => $cliente));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "Error al modificar", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:18,代码来源:UsuarioControl.php

示例9: postCalificacion

 function postCalificacion(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $idEmpresa = $request->getAttribute('email');
     $data = json_decode($request->getBody(), true);
     try {
         $ce = new CalificacionEmpresa();
         $ce->calificacion = $data['calificacion'];
         $ce->idEmpresa = $idEmpresa;
         $ce->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1, "obj" => $data));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "erro al calificar", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:19,代码来源:EmpresaControl.php

示例10: post

 function post(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $calificacion = new CalificacionCliente();
         $calificacion->idCliente = $data['idCliente'];
         $calificacion->idEmpleado = $data['idEmpleado'];
         $calificacion->calificacion = $data['calificacion'];
         $calificacion->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "error", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:19,代码来源:CalificacionClienteControl.php

示例11: addgaleria

 function addgaleria(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $id = $request->getAttribute("id");
         $galeria = new Galeria();
         $galeria->logo = $data['logo'];
         $galeria->idSucursal = $data['idsucursal'];
         $galeria->fecha = fechaHoraActual();
         $galeria->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "error", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:20,代码来源:GaleriaControl.php

示例12: postSucursales

 function postSucursales(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $sucursal = new Sucursal();
         $sucursal->nombre = $data['nombre'];
         $sucursal->direccion = $data['direccion'];
         $sucursal->latitud = $data['latitud'];
         $sucursal->longitud = $data['longitud'];
         $sucursal->idEmpresa = $data['idEmpresa'];
         $sucursal->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1, "obj" => $data));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "La sucursal ya existe", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:21,代码来源:SucursalControl.php

示例13: putFoto

 function putFoto(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $idOferta = $request->getAttribute('id');
     $data = $request->getBody();
     try {
         $fp = fopen($idOferta . '.jpg', 'wb');
         fwrite($fp, $data);
         fclose($fp);
         $fo = new FotosOferta();
         $fo->foto = $rutaServidor . "fotos/" . $idOferta . ".jpg";
         $fo->idOferta = $idOferta;
         $fo->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1, "obj" => $data));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "Error al guardar foto oferta", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:22,代码来源:OfertaControl.php

示例14: postCategoriasSucursal

 function postCategoriasSucursal(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $id = $request->getAttribute('id');
     $data = json_decode($request->getBody(), true);
     try {
         $cc = CategoriasSucursal::where('id', '=', $id)->first();
         $cc->delete();
         for ($i = 0; $i < count($data['categorias']); $i++) {
             $cc = new CategoriasSucursal();
             $cc->idCategoria = $data['categorias'][$i];
             $cc->idSucursal = $id;
             $cc->save();
         }
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1, "obj" => $data));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "La empresa ya existe", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:BuscaloApi,代码行数:23,代码来源:CategoriaControl.php

示例15: postTurnoRecurrente

 public function postTurnoRecurrente(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     $fechaReserva = $data['fechaReserva'];
     $rango = $data["rango"];
     $meses = $data["meses"];
     $fechaFinal = strtotime("+{$meses} month", strtotime($fechaReserva));
     $fechaFinal = date('Y/m/d', $fechaFinal);
     $datetime1 = new DateTime($fechaReserva);
     $datetime2 = new DateTime($fechaFinal);
     $interval = $datetime1->diff($datetime2);
     $minutosServicio = ServiciosSucursal::select("minutos")->where("idServicio", "=", $data["idServicio"])->where("idSucursal", "=", $data["idSucursal"])->first();
     /*
       Valores de Rangos 
       
       diario = 1
       semanal = 2
       mensual = 3
     */
     switch ($rango) {
         case '1':
             $tiempo = floor($interval->format('%a'));
             break;
         case '2':
             $tiempo = floor($interval->format('%a') / 7);
             break;
         default:
             $tiempo = $meses;
             break;
     }
     //echo $tiempo;
     $fecha = $fechaReserva;
     for ($i = 0; $i <= $tiempo; $i++) {
         switch ($rango) {
             case '1':
                 $fechaReservaFinal = strtotime("+1 day", strtotime($fecha));
                 $fechaReservaFinal = date('Y/m/d', $fechaReservaFinal);
                 break;
             case '2':
                 $fechaReservaFinal = strtotime("+7 day", strtotime($fecha));
                 $fechaReservaFinal = date('Y/m/d', $fechaReservaFinal);
                 break;
             default:
                 $fechaReservaFinal = strtotime("+1 month", strtotime($fecha));
                 $fechaReservaFinal = date('Y/m/d', $fechaReservaFinal);
                 break;
         }
         $respuesta = null;
         try {
             $turno = new Turno();
             $turno->idCliente = $data['idCliente'];
             $turno->idEmpleado = $data['idEmpleado'];
             $turno->idSucursal = $data['idSucursal'];
             $turno->idServicio = $data['idServicio'];
             $turno->tiempo = 0;
             $turno->turno = 0;
             $turno->turnoReal = 0;
             $turno->tipoTurno = 1;
             $turno->estadoTurno = "SOLICITADO";
             $turno->estado = "ACTIVO";
             $turno->reserva = "A";
             $turno->fechaReserva = $fecha;
             $turno->horaReserva = $data['horaReserva'];
             $horaInicial = $data['horaReserva'];
             for ($j = 0; $j < $data["cupos"]; $j++) {
                 $segundos_horaInicial = strtotime($horaInicial);
                 $segundos_minutoAnadir = $minutosServicio->minutos * 60;
                 $nuevaHora = date("H:i", $segundos_horaInicial + $segundos_minutoAnadir);
                 $horaInicial = $nuevaHora;
             }
             $turno->horaFinalReserva = $nuevaHora;
             $turno->save();
             $fecha = $fechaReservaFinal;
             $respuesta = json_encode(array('msg' => "Su turno ha sido asignado satisfactoriamente.", "std" => 1, 'idTurno' => $turno->id));
             $response = $response->withStatus(200);
         } catch (Exception $err) {
             $respuesta = json_encode(array('msg' => "error al pedir el turno", "std" => 0, "err" => $err->getMessage()));
             $response = $response->withStatus(404);
         }
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
开发者ID:giocni93,项目名称:Apiturno,代码行数:84,代码来源:TurnoControl.php


注:本文中的Slim\Http\Request::getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。