How to list EXC exchange information in PHP via API?

0

Using PHP, how to list EXC API information, I'm having some difficulties and who I can help,

Details: LINK API :

Here is an example of how I tried to do it:

<?php
    $json = file_get_contents("https://trade.exccripto.com/api/v3/public/getticker?market=DCR_BTC");
    $coins = json_decode($json);
?>

<table style="width:100%">
 <tbody>
  <tr>                                                          
   <th>Market</th>
   <th>Bid</th>
   <th>Ask</th>
   <th>Last</th>                                                            
  </tr>                                                       
 <?php foreach ($coins as $coin) { ?>
 <tr>                                                           
  <td><?php echo $coin->Market; ?></td>
  <td><?php echo $coin->Bid; ?></td>
  <td><?php echo $coin->Ask; ?></td>
  <td><?php echo $coin->Last; ?></td>    
 </tr>
<?php } ?>
</tbody>
    
asked by anonymous 23.12.2018 / 22:30

1 answer

0

In this part of the code you forgot to specify the result where I believe to be the collection of information:

JSON :

{"success":true,
 "message":"",
 "result":[{
     "Market":"DCR_BTC",
     "Bid":0.00452230,
     "Ask":0.00489226,
     "Last":0.00479230
    }]
}

Example with change:

<?php foreach ($coins->result as $coin) { ?>
<tr> 
    <td><?php echo $coin->Market; ?></td>
    <td><?php echo $coin->Bid; ?></td>
    <td><?php echo $coin->Ask; ?></td>
    <td><?php echo $coin->Last; ?></td>
</tr>
<?php } ?>

That is, you were not putting the proposed key in the and therefore could not find the items of your table .

    
24.12.2018 / 01:39