PHP code example of juniorfontenele / perguntados

1. Go to this page and download the library: Download juniorfontenele/perguntados 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/ */

    

juniorfontenele / perguntados example snippets



use Perguntados\Perguntados;
$Perguntados = new Perguntados();

$games = $Perguntados->getGames();
foreach ($games as $game) {
    echo $game->toJson();
}

$gameId = '1234567890';
$game = $Perguntados->getGame($gameId);
echo $game->toJson();

try {
    $Perguntados->winGame($game);
} catch(Exception $e) {
    echo "Failed to win game: " . $e->getMessage();
}

try {
    $Perguntados->winRandomDuel();
} catch(Exception $e) {
    echo "Failed to win random game: " . $e->getMessage();
}