Trying to get property of non-object
means one of the ->property
call failed because that property does not exist. In this case, it's the $o->result that failed.
If you print out content of $array, you can see it's structured like this:
print_r($array);
output:
stdClass Object
(
[success] => 1
[message] =>
[result] => Array
(
[0] => stdClass Object
(
[Id] => 10044
[TimeStamp] => 2014-06-12T04:36:32.227
[Quantity] => 3
[Price] => 2.9E-5
[Total] => 8.7E-5
[FillType] => FILL
[OrderType] => BUY
)
[1] => stdClass Object
(
[Id] => 10040
[TimeStamp] => 2014-06-12T04:23:22.683
[Quantity] => 49.9
[Price] => 2.5E-5
[Total] => 0.0012475
[FillType] => PARTIAL_FILL
[OrderType] => SELL
)
...
Now you can follow this structure to get the inner objects:
<?php
$json_string = file_get_contents("https://bittrex.com/api/v1/public/getmarkethistory?market=BTC-HYPER&count=5");
echo "<table>\n";
$array = json_decode($json_string);
foreach ($array->result as $o) {
echo "<tr><td>$o->TimeStamp</td></tr>\n";
}
echo "</table>\n";
outputs:
<table>
<tr><td>2014-06-12T04:36:32.227</td></tr>
<tr><td>2014-06-12T04:23:22.683</td></tr>
<tr><td>2014-06-12T04:01:43.217</td></tr>
<tr><td>2014-06-12T02:02:29.03</td></tr>
...