View Single Post
  #1   Spotlight this post!  
Unread 23-03-2008, 17:50
SamC SamC is offline
.
AKA: Sam Couch
FRC #0103 (Cybersonics)
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Philadelphia, PA
Posts: 583
SamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond repute
[TBA]: Example Code Addition

Here is a recreation of the example code that comes with the new TBA API. Basically it will generate the performance history of your team as well as videos from the year you indicate. Here's the code,
PHP Code:
<?
//this file demonstrates the use of four core functions in The Blue Alliance API.
//CONFIGURATION
//Change to your path to tba_api_client_PHP5.php
include 'tba_api_client_PHP5.php';

$teamnumber 330;
$season 2007;
$colorA '0033FF';
$colorB 'FFFF00';
$colorC '0033FF';

//get team
$teams make_array(get_teams($teamnumber));

//show team data
$overall_record make_array(get_official_record($teamnumber));

//introduction and basic information
echo "<p>Below is some information about our team, {$teams[0]["informalname"]}, from {$teams[0]["city"]}{$teams[0]["state"]}. Our overall record at official events is {$overall_record[0]["string"]}.</p>";

echo 
"<table id=\"list_events\">";
echo 
"<tr><th>Year</th><th>Event</th><th>Record</th><th>Wins</th></tr>";
$future "";
$team_events make_array(get_attendance(NULL$teamnumber));

foreach (
$team_events as $attendance)
{
  echo 
"<tr>";
  
//get event record
  
$event make_array(get_events($attendance["eventid"]));
  
  
//show the user some data about this event
  
if ($event[0]["official"] == false) {
    
$official_text "*";
  }
  
  
//get team's record at event
  
$record make_array(get_official_record($teamnumber$event[0]["eventid"]));
  
  
//show data to user
  
if ($record[0]["sum"] != 0) { $percent round(($record[0]["win"] / $record[0]["sum"]) * 100) . "%"; } else { $percent "0%"; }
  echo 
"<td><a target=\"_blank\" href=\"http://www.thebluealliance.net/tbatv/eventlist.php?year={$event[0]["year"]}\">{$event[0]["year"]} </a></td>";
  echo 
"<td><a target=\"_blank\" href=\"{$event[0]["tba_link"]}\">{$event[0]["name"]}</a>{$official_text}</td>";
  echo 
"<td>({$record[0]["string"]})</td>";
  echo 
"<td>Won {$percent}</td>";
  echo 
"</tr>";
}
  
echo 
"</table>";

?>

Here are also some videos from our <?php print $season ?> season.
<iframe src="http://www.thebluealliance.net/tbatv/iframe_playlist.php?frontcolor=<?php print $colorA ?>&backcolor=<?php print $colorB ?>&lightcolor=<?php print $colorC ?>&year=<?php print $season ?>&team=<?php print $teamnumber ?>" frameborder="0" height="470" width="395" scrolling="no"></iframe>

Content courtesy TheBlueAlliance.net
Heres is an example of it in action, here

Last edited by SamC : 23-03-2008 at 17:56.
Reply With Quote