PHP code example of nataniel / bggxmlapi2

1. Go to this page and download the library: Download nataniel/bggxmlapi2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nataniel / bggxmlapi2 example snippets


// initialize client
$client = new \Nataniel\BoardGameGeek\Client();

// download information about "Dixit"
// https://boardgamegeek.com/boardgame/39856/dixit
$thing = $client->getThing(39856, true);

var_dump($thing->getName());
var_dump($thing->getYearPublished());
var_dump($thing->getBoardgameCategories());
var_dump($thing->getRatingAverage());
// ...

// download information about user
// https://boardgamegeek.com/user/Nataniel
$user = $client->getUser('nataniel');

var_dump($user->getAvatar());
var_dump($user->getCountry());

// search for a game
$results = $client->search('Domek');
echo count($results);

$things = [];
foreach ($result as $item) {
    var_dump($item->getName());
    $things[] = $client->getThing($item->getId());
}