Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: the founder on April 03, 2013, 02:43:56 PM



Title: I need help with campbx's api
Post by: the founder on April 03, 2013, 02:43:56 PM
I need this

http://campbx.com/api/xticker.php

which outputs this

{"Last Trade":"140.21","Best Bid":"137.50","Best Ask":"140.00"}

to output just

140.21

Nothing more...  in PHP .. each time I try it I get an unexpected result...   

Can someone post a quick source on how to output it in this format?   It's to help with average spot price from all the exchanges,  campbx is one that for some reason gives me trouble even though it looks simple.


<? php 

FILL IN CODE HERE

?>

Seriously I would appreciate it...   



Title: Re: I need help with campbx's api
Post by: matt.collier on April 05, 2013, 12:47:29 AM
<?php
$tuData = '{"Last Trade":"140.21","Best Bid":"137.50","Best Ask":"140.00"}';
$obj = json_decode($tuData);
$lastTrade = $obj->{"Last Trade"};
echo "Last Trade: ".$lastTrade."\n";
?>


Title: Re: I need help with campbx's api
Post by: the founder on April 05, 2013, 01:14:50 AM
Thank you so much I'm on my mobile now but I'm going to test this second I get home!!