juniorfontenele/perguntados

API for Preguntados Game from Etermax

v1.0.3 2016-01-28 22:17 UTC

This package is auto-updated.

Last update: 2024-11-10 19:38:36 UTC


README

An API to Preguntados Game by Etermax

This package provides an interface to interact with 'Preguntados' Game from Etermax

Requirements

You'll need to have an open session with Preguntados Game and know your Preguntados' user_id. You can access this information following this tutorial.

Instalation

The easiest way to install this package is using composer:

composer require juniorfontenele/perguntados

Usage

  • Rename .env.example to .env
  • Replace 'USER_ID' with your Preguntados' USER ID
  • Replace 'APP_COOKIE' with your Preguntados' session cookie (ap_session)
  • Import Perguntados Class to your file:
require_once __DIR__ . '/../../vendor/autoload.php';
use Perguntados\Perguntados;
$Perguntados = new Perguntados();

List All Pending and Active Games

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

Get Info on a specific game

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

Win a Game

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

Play and Win a Random Duel

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

License

The MIT License (MIT). Please see License File for more information.