Ejemplo n.º 1
0
<?php

require './inc/config.inc.php';
require './inc/header.php';
define('PHP_SELF', htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'));
try {
    $m = new YahooMessageArchiver(TRUE);
} catch (OauthException $e) {
    echo 'ERROR: Response: ', $e->lastResponse, PHP_EOL;
    exit;
}
$guid = $m->retrieve('http://social.yahooapis.com/v1/me/guid');
if (!$guid->value) {
    $guid = 'unknown';
} else {
    $guid = (string) $guid->value;
}
?>

<h1>Run Yahoo arbritrary REST commands</h1>
<p>Note: The "http://fantasysports.yahooapis.com/fantasy/v2/" part is optional and the default.</p>
<p>Note: We determined your GUID is: <strong><?php 
echo $guid;
?>
</strong> so replace {guid} with it where needed.</p>
<p>Note: This OAuth token is specific to Fantasy Sports although a lot of other (but not all) information can be accessed here too. Like your profile.</p>
<p>Examples:</p>
<ul>
 <li>View your team(s) info: users;use_login=1/games;game_keys=nfl,mlb,nba,nhl/teams [<a href="<?php 
echo PHP_SELF;
?>
Ejemplo n.º 2
0
require './inc/header.php';
// @todo add proper error reporting
if (empty($_VARS['week_num']) || empty($_VARS['league_key'])) {
    echo 'Error: A week number and league key is required for matchup information';
    exit;
}
try {
    $m = new YahooMessageArchiver(TRUE);
} catch (OauthException $e) {
    echo 'ERROR: Response: ', $e->lastResponse, PHP_EOL;
    exit;
}
$query = "league/{$_VARS['league_key']}/scoreboard;week={$_VARS['week_num']}/matchups/teams/roster;week={$_VARS['week_num']}/players/stats;type=week;week={$_VARS['week_num']}";
// For single team
// $query = "team/{$team_key}/roster;week={$week_num}/players/stats;type=week;week={$week_num}
$minfo = $m->retrieve($query);
// @todo fix questionable error handling
if (empty($minfo)) {
    echo "FAIL";
    exit;
}
echo '<h1>Matchup information for week ', $minfo->league->scoreboard->week, '</h1>';
// @todo remove this hack
// @todo show more info
foreach ($minfo->league->scoreboard->matchups->matchup as $key => $values) {
    $team_name_0 = $values->teams->team[0]->name;
    $team_name_1 = $values->teams->team[1]->name;
    // @todo Assuming one manager for now
    $team_nick_0 = $values->teams->team[0]->managers->manager->nickname;
    $team_nick_1 = $values->teams->team[1]->managers->manager->nickname;
    $team_score_0 = $values->teams->team[0]->team_points->total;
$lid = empty($_GET['lid']) ? FALSE : trim($_GET['lid']);
$type = empty($_GET['type']) ? 'add' : trim($_GET['type']);
/*
if (empty($lids)) {
	$lids = $m->getLeagueIds( TRUE );
	if ( !$lids ) {
		echo 'Error: Unable to find league ids for you.', PHP_EOL;
		exit;
	}
}
*/
if (empty($lid)) {
    $lid = '238.l.627060';
    // public baseball league, for testing
}
$transactions = $m->retrieve("http://fantasysports.yahooapis.com/fantasy/v2/league/{$lid}/transactions;type={$type}");
echo "<p>Query is for league id '{$lid}' searching for transaction types '{$type}'</p>";
echo '<table border="1">';
foreach ($transactions->league->transactions->transaction as $t) {
    $team_key = 'unknown';
    if (isset($t->players->player->transaction_data->destination_team_key)) {
        $team_key = (string) $t->players->player->transaction_data->destination_team_key;
    }
    if (empty($team_names[$team_key])) {
        $team_names[$team_key] = $team_key;
    }
    echo '<tr>';
    echo '<td>', $t->players->player->name->full, '</td>';
    echo '<td>', $team_names[$team_key], '</td>';
    echo '<td>', date('Y m d', (int) $t->timestamp), '</td>';
    echo '<td>', $t->players->player->transaction_data->source_type, '</td>';