Search code examples
phpobjectbitcoin

Coinbase API, Trying to get property of non object


I was just messing around with the coinbase api, and am getting an error. Basically I was saying if the transaction was successful, then just simply echo the information (like transaction id), but I get an error: http://puu.sh/4onKP.png Here is the most important parts of my code...

$result = $coinbase->sendMoney($address, $amount, "Thank you for using nahtnam's Faucet! - Best Regards, nahtnam");
$address_success = $response->success ? 'true' : 'false';
$address_status = $response->transaction->status;
$address_id = $response->transaction->id;
$address_amount = $response->transaction->amount->amount;

And also here is where i display the information...

elseif(isset($response['success']) && $response['success'] == 'true') {
    echo '
    <div class="row">
    <div class="col-lg-12">
    <center>
    <div class="alert alert-dismissable alert-success">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <strong>Your Bitcoins have been sent!</strong><br>We have successfully sent '.$amount.' to your Bitcoin Address: '.$address.'... Here is some more info on the transaction:<br>Address: '.$address.'<br> Amount: '.$amount.'<br>Transaction Id: '.$address_id.'<br> Transaction Status: '.$address_status.'<br>Thank you for using nahtnam\'s Coinbase faucet. You can come back in <strong>30 Minutes</strong> to claim more!</a>.
    </div>
    </center>
    </div>
    </div>
    ';
    }

Thanks for all the help! :)


Solution

  • First, your sendMoney() call is stored into $result and you are referencing an object called $response, which based on the error doesn't exist.