Hi people,
I'm using this very small script to pull and display some API info from either bitstamp.net/api/ticker/ and blockchain.info/ticker APIs. The script is currently pulling the info from Mt Gox but it's no longer working because they are out of business. Any help fixing this would be greatly appreciated. This is for a site I'm designing for a client:
BitcoinValues.net.
Thank you
Code:
1.<?php
2. //first fetch the current rate from MtGox
3. $ch = curl_init('https://mtgox.com/api/0/data/ticker.php');
4. curl_setopt($ch, CURLOPT_REFERER, 'Mozilla/5.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
5. curl_setopt($ch, CURLOPT_USERAGENT, "CakeScript/0.1");
6. curl_setopt($ch, CURLOPT_HEADER, 0);
7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
8. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
9. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
10. $mtgoxjson = curl_exec($ch);
11. curl_close($ch);
12.
13. //decode from an object to array
14. $output_mtgox = json_decode($mtgoxjson);
15. $output_mtgox_1 = get_object_vars($output_mtgox);
16. $mtgox_array = get_object_vars($output_mtgox_1['ticker']);
17.
18. ?>
19. <br/>
20. <br/>
21. Last: <?php echo $mtgox_array['last']; ?><br/>
22. High: <?php echo $mtgox_array['high']; ?><br/>
23. Low: <?php echo $mtgox_array['low']; ?><br/>
24. Avg: <?php echo $mtgox_array['avg']; ?><br/>
25. Vol: <?php echo $mtgox_array['vol']; ?><br/>