Skip to content

Instantly share code, notes, and snippets.

@zQueal
Created February 5, 2014 03:24
Show Gist options
  • Save zQueal/8816972 to your computer and use it in GitHub Desktop.
Save zQueal/8816972 to your computer and use it in GitHub Desktop.
Uses cURL to pull the current price of BTC in USD.
#!/usr/bin/env php
<?php
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($c, CURLOPT_URL, 'http://data.mtgox.com/api/2/BTCUSD/money/ticker');
$data = curl_exec($c);
curl_close($c);
$obj = json_decode($data);
echo print_r($obj->{'data'}->{'avg'}->{'display_short'}."\n", true);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment