Last active
August 29, 2015 14:01
-
-
Save albertosilletti/4584f5b76deb8bdbcfcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*** MTGO Library API Example ***/ | |
// build the url to the api | |
$url = 'https://www.mtgolibrary.com/web_shops/inventory?' . http_build_query(array( | |
'bot' => 'YOUR_BOT_NAME_HERE', // your username | |
'key' => 'YOUR_API_KEY_HERE', // your api key | |
'set_name' => 'BNG', // the set name to download | |
)); | |
// download the inventory | |
$inventory = json_decode(file_get_contents($url), true); | |
// create a table with the cards | |
?> | |
<table> | |
<thead> | |
<tr> | |
<th>Card Name</th> | |
<th>Set Name</th> | |
<th>Rarity</th> | |
<th>Bot</th> | |
<th>Foil</th> | |
<th>Buy Price</th> | |
<th>Buy Quantity</th> | |
<th>Sell Price</th> | |
<th>Sell Quantity</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php foreach ($inventory as $card) { ?> | |
<tr> | |
<td><?php echo stripslashes(urldecode($card['card_name'])); ?></td> | |
<td><?php echo $card['set_name']; ?></td> | |
<td><?php echo $card['rarity']; ?></td> | |
<td><?php echo urldecode($card['bot']); ?></td> | |
<td><?php echo $card['foil'] ? 'foil' : ''; ?></td> | |
<td><?php echo $card['buy_price']; ?></td> | |
<td><?php echo $card['buy_quantity']; ?></td> | |
<td><?php echo $card['sell_price']; ?></td> | |
<td><?php echo $card['sell_quantity']; ?></td> | |
</tr> | |
<?php } ?> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment