Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design Trapping and storing Json data Reply To: Trapping and storing Json data

#257241
JeroenR
Participant

I would start with a simple empty PHP page that examines the POST data.

<?php  
    $json = file_get_contents("php://input");  

    if (empty($json)) {  
        echo "No data payload";  
        die;  
    }

    $contact = json_decode($json);  
    if ($contact == null && json_last_error() !== JSON_ERROR_NONE) {  
        echo "Error reading JSON: " . json_last_error();  
    }

    var_dump($contact);
?>

From there see what the contents really is and do with it what you like. For all things you describe should be a solution that you can easily find by googling the separate functions like file writing and storing data somewhere.

If you get no result from the code above you can also just start with this:

<?php print_r($_POST); ?>

See if there is anything posted.

Save that PHP page somewhere in your domain and enter the URL to that page in ‘Post JSON data to a website’.
According to the documentation that should work, assuming your provider supports PHP.
For checking that, you can use:

<?php phpinfo(); ?>

Save it as a .php file, upload it and navigate to it on your website.

Did you try the request bin example by any chance? Because that should show you there is indeed posted data. Maybe that is easier to start with.