public function updateMatchesFromChallonge()
 {
     $c = new ChallongeAPI(Yii::app()->params['challonge_api']);
     $params = array();
     $matches = $c->getMatches($this->challonge_id, $params);
     foreach ($matches as $k => $match) {
         $_match = Match::model()->findByAttributes(array('tournament_id' => $this->id, 'challonge_match_id' => $match->match->id));
         if ($_match) {
             $_match->team_1 = strlen($match->match->player1_id) ? $match->match->player1_id : '';
             $_match->team_2 = strlen($match->match->player2_id) ? $match->match->player2_id : '';
             $_match->identifier = $match->match->identifier;
             $_match->round = $match->match->round;
             $_match->state = $match->match->state;
             $_match->winner = $match->match->winner_id;
             $_match->loser = $match->match->loser_id;
             $_match->save();
         }
     }
 }
Esempio n. 2
0
require $_SERVER['DOCUMENT_ROOT'] . '/includes/modules/tournamentManagement/challonge.class.php';
// Create a new instance of the API wrapper. Pass your API key into the constructor
// You can view/generate your API key on the 'Password / API Key' tab of your account settings page.
$c = new ChallongeAPI('vbAqvSEkokYx74ZIIMP7wUgVZLOzq7VzgF2CBetW');
/*
  For whatever reason (example: developing locally) if you get a SSL validation error from CURL,
  you can set the verify_ssl attribute of the class to false (defualts to true). It is highly recommended that you
  **NOT** do this on a production server.
*/
$c->verify_ssl = true;
$tournament_id = 'testtournamentlanops';
$params = array("include_matches " => 0);
$tournament = $c->makeCall("tournaments/{$tournament_id}", $params, "get");
$tournament = $c->getTournament($tournament_id, $params);
echo '<pre>';
print_r($c->result);
echo '</pre>';
// MATCHES EXAMPLES
// ************************
// Get all matches for a tournament
// http://challonge.com/api/tournaments/:tournament/matches
$matches = $c->makeCall("tournaments/{$tournament_id}/matches", $params);
$matches = $c->getMatches($tournament_id, $params);
echo '<pre>';
print_r($c->result);
echo '</pre>';
$participants = $c->makeCall("tournaments/{$tournament_id}/participants");
$participants = $c->getParticipants($tournament_id);
echo '<pre>';
print_r($c->result);
echo '</pre>';