$m->printR($m->getLog()); echo 'Error: Did not receive authentication url. Hmm...', PHP_EOL; exit; } header('Location: ' . $response['xoauth_request_auth_url']); exit; } else { // @todo add error reporting echo 'Error: Unknown problem.' . PHP_EOL; exit; } } /******************************************************************************************************************************************** /** Stage #2: Access Token /********************************************************************************************************************************************/ if (!($request_token_info = $m->getStoredInfo())) { echo 'Error: Unable to locate request token information. Try requesting it again.', PHP_EOL; $m->printR($m->getLog()); exit; } if (empty($request_token_info)) { echo 'Error: no request information, info is empty. Try requesting it again.', PHP_EOL; exit; } if ($request_token_info && is_array($request_token_info)) { $o->setToken($request_token_info['oauth_token'], $request_token_info['oauth_token_secret']); if (empty($_GET['oauth_verifier'])) { echo 'Missing oauth_verifier.', PHP_EOL; exit; } $response = $o->getAccessToken('https://api.login.yahoo.com/oauth/v2/get_token', NULL, $_GET['oauth_verifier']);
<?php require './inc/config.inc.php'; require './inc/header.php'; try { $m = new YahooFantasyAPI(TRUE); } catch (OauthException $e) { echo "ERROR: Response: " . $e->lastResponse . PHP_EOL; exit; } try { $info = $m->getStoredInfo(); $ids = $m->getLeagueIds(FALSE); // Get league keys foreach ($ids as $id) { // @todo A few are missing this, research this if (FALSE === strpos($id['url'], 'http://')) { $id['url'] = 'http://football.fantasysports.yahoo.com' . $id['url']; } $ldata[] = array('league_key' => $id['league_key'], 'league_id' => $id['league_id'], 'url' => $id['url'], 'season' => $id['season'], 'name' => $id['name']); } echo "<h3>All leagues you have played in</h3>"; echo "<ul>"; foreach ($ldata as $data) { echo "<li><a href='{$data['url']}'>{$data['name']} ({$data['season']})</a></li>"; } echo "</ul>"; } catch (OAuthException $e) { print "<pre>"; echo "Exception caught!\n"; echo "Response: " . $e->lastResponse . "\n";