ciao!
sto cercando di mettere su un service con Slim 3.
l'ho installato e il get sembra funzionare.
ho però un problema con le richieste post.
questo il php:
Codice PHP:
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require_once './vendor/autoload.php';
$config['displayErrorDetails'] = true;
$config['db']['host'] = "";
$config['db']['user'] = "";
$config['db']['pass'] = "";
$config['db']['dbname'] = "";
$app = new \Slim\App(["settings" => $config]);
$app->post('/admin/login', function (Request $request, Response $response) {
$data = $request->getParsedBody();
var_dump($data);
});
$app->run();
a questo punto ho provato il tutto con curl:
codice:
$ curl -i -H "Content-Type: application/json" -X POST -d '{"username": "...", "password: "..."}' http://www.sito.com/admin/login
HTTP/1.1 200 OK
Date: Wed, 23 Mar 2016 14:28:38 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Content-Length: 5
Content-Type: text/html; charset=UTF-8
NULL
come vedete ottengo sempre NULL in risposta.
che sto sbagliando??