Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 3.1.8 JSON Post fails
#2

It looks okay to me...
Make sure that file_get_contents are activated by trying it on another resource.  ->raw_input_stream utilizes that function.

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Postman extends CI_Controller {
    
    public function 
index()
    {
 
       if$this->input->is_ajax_request() )
 
       {
            
$json $this->input->raw_input_stream;
            
$json json_decode($json);
            
/**
            $json now looks like
                stdClass Object
                (
                    [user] => 1
                )
                
            Access it like
            echo $json->user;
            **/
            
            // Process json...
            
            // Data to send back
            
$data = array('success' => 'true');
            
            
// Send back json
            
$this->output
                    
->set_content_type('application/json')
                    ->
set_output(json_encode($data));
 
       }
    }


Postman settings:
Content-Type: application/json
X-Requested-With: xmlhttprequest
Reply


Messages In This Thread
Codeigniter 3.1.8 JSON Post fails - by pigfox - 05-12-2018, 08:58 PM
RE: Codeigniter 3.1.8 JSON Post fails - by jreklund - 05-13-2018, 01:27 AM
RE: Codeigniter 3.1.8 JSON Post fails - by pigfox - 05-13-2018, 10:58 AM
RE: Codeigniter 3.1.8 JSON Post fails - by pigfox - 05-13-2018, 02:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB