Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Problemi con Slim 3 e richieste post

    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 $requestResponse $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??

  2. #2
    era sbagliata la stringa json mandata con curl.
    al campo password manca il doppio apice di chiusura.
    scusate!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.