I'm loking for a PHP script to show the last price on MtGox. This is to be used on a website.
Anyone have this available?
Variable $last is the last price.
$ch = curl_init('https://data.mtgox.com/api/2/BTCUSD/money/ticker');
curl_setopt($ch, CURLOPT_REFERER, 'Mozilla/5.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
curl_setopt($ch, CURLOPT_USERAGENT, "CakeScript/0.1");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$mtgoxjson = curl_exec($ch);
curl_close($ch);
$output_mtgox = json_decode($mtgoxjson);
$output_mtgox_1 = get_object_vars($output_mtgox);
$mtgox_array = get_object_vars($output_mtgox_1['data']);
$data = get_object_vars($mtgox_array['last']);
$last = $data['value'];
?>
If this helped you out, I would appreciate a donation of any size - 1JFs4LNkRF4t96r8EJ6FNaaLmcY9SQGEmG