Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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:

{"type":"buy_now","name":"Test Item","description":null,"id":null},"transaction":
share|improve this question
Could you put var_dump($_POST); in your callback and post the output? – Nick ODell Feb 8 '13 at 2:22
I just tried $data = var_dump($_POST); file_put_contents('coinbase.txt', $data); with no luck. – fwho Feb 8 '13 at 2:32
Ah, of course. It's been a while since I've done any php. Try $data = print_r($_POST, TRUE); file_put_contents('coinbase.txt', $data); – Nick ODell Feb 8 '13 at 2:34
I got Array ( ) It is a step forward though! – fwho Feb 8 '13 at 2:40
Do you have a shell on this computer? If so, you could do nc -l 8080, then set the callback url to to see exactly what it's sending. – Nick ODell Feb 8 '13 at 4:36
up vote 0 down vote accepted
$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:

    [order] => Array
            [id] => 
            [created_at] => 
            [status] => new
            [total_btc] => Array
                    [cents] => 100000000
                    [currency_iso] => BTC

            [total_native] => Array
                    [cents] => 2270
                    [currency_iso] => USD

            [custom] => 123456789
            [button] => Array
                    [type] => buy_now
                    [name] => Test Item
                    [description] => 
                    [id] => 

            [transaction] => Array
                    [hash] => 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
                    [confirmations] => 0


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.