How to retrieve POST data that contains JSON I have never used JSON before and am trying to retrieve the values POSTed to my site from coinbase. But I have no idea how to.

Information about the IPN and callback can be found here: https://coinbase.com/docs/merchant_tools/callbacks

To be more specific, what I understand so far is that I can use json_decode($jsonData); to turn the JSON data into PHP data. But how do I set the variable $jsonData?

This is the response that is supposed to be sent:

{"order":{"id":null,"created_at":null,"status":"new","total_btc":
{"cents":100000000,"currency_iso":"BTC"},"total_native":
{"cents":2263,"currency_iso":"USD"},"custom":"123456789","button":
{"type":"buy_now","name":"Test Item","description":null,"id":null},"transaction":
{"hash":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b","confirmations":0}}}
$data = json_decode(file_get_contents('php://input'), TRUE);
$text = print_r($data,true);
file_put_contents('coinbase.txt', $text);


This actually sends the following information to a text file:

Array
(
    [order] =&gt; Array
        (
            [id] =&gt; 
            [created_at] =&gt; 
            [status] =&gt; new
            [total_btc] =&gt; Array
                (
                    [cents] =&gt; 100000000
                    [currency_iso] =&gt; BTC
                )

            [total_native] =&gt; Array
                (
                    [cents] =&gt; 2270
                    [currency_iso] =&gt; USD
                )

            [custom] =&gt; 123456789
            [button] =&gt; Array
                (
                    [type] =&gt; buy_now
                    [name] =&gt; Test Item
                    [description] =&gt; 
                    [id] =&gt; 
                )

            [transaction] =&gt; Array
                (
                    [hash] =&gt; 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
                    [confirmations] =&gt; 0
                )

        )

)