The Ticket

This site doesn’t exist without The Ticket 1310 AM KTCK. They have a perfect mix of guy talk and sports with it’s listeners (P1’s) latching on to a teet and never letting go.

The Ticket on-air crew are what make this station kick ass. Ever wonder wear they rank in the nation of broadcasters? How about how popular they are with twitter followers? Here ya go. Real-time data for your bottom.

Cannot Access DB

‘, E_USER_ERROR );
}

$buf =

\n”.

\n”.

\n”.

\n”.

\n”.

\n”.

\n”.

\n”.

\n”;

$query = “SELECT * FROM theticket_hosts “;
$query .= “ORDER BY followers DESC”;

$result = mysql_query( $query ) or trigger_error( mysql_error(), E_USER_ERROR );

// how old can the stats be before we refresh them?
$ts = strtotime( ’30 minutes ago’ );

while ( $HOST = mysql_fetch_assoc( $result ) )
{
if ( $HOST[‘updated’] < $ts ) { getStats( $HOST ); } $buf .= "

\n”.

\n”.

\n”.

\n”.

\n”.

\n”.

\n”;
}

$buf .=

\n”.

Host Show PowerGrid   Followers
“.htmlentities( $HOST[‘name’] ).” “.htmlentities( $HOST[‘show’] ).” “.( $HOST[‘powergrid’] ? number_format( $HOST[‘powergrid’] ) : ‘-‘ ).”   “.( $HOST[‘followers’] ? number_format( $HOST[‘followers’] ) : ‘-‘ ).”

 

\n”;

echo $buf;

function getStats ( &$HOST )
{
// set up defaults
$UPDATES = array( ‘updated = ‘.time() );

// SportsGrid:
// form URL to query
$sportsgrid_url = “http://www.sportsgrid.com/power-grid/radio-hosts/$HOST[sportsgrid]/”;

// Get raw HTML from urls
$sportsgrid_html = curlIt( $sportsgrid_url );

// process sportsgrid raw output for powergrid
// set up pattern
$sportsgrid_pattern = ‘|’.preg_quote( ‘

#‘ ).'([0-9,]+)|’;

if ( preg_match( $sportsgrid_pattern, $sportsgrid_html, $MATCHES ) )
{
$powergrid = preg_replace( ‘/[^0-9]+/’, ”, $MATCHES[1] );

$HOST[‘powergrid’] = $powergrid;

$UPDATES[] = “powergrid = “.intval( $powergrid );
}

// Twitter second method:
// form URL to query
$twitter_url = “http://twittercounter.com/compare/$HOST[twitter]/week/followers”;

// Get raw HTML from urls
$twitter_html = curlIt( $twitter_url );

// process twitter raw output for followers
// set up pattern
$twitter_pattern = ‘|’.preg_quote( ‘‘ ).'([^\<]+)'.preg_quote( ' Followers‘ ).’|i’;

if ( preg_match( $twitter_pattern, $twitter_html, $MATCHES ) )
{
$followers = preg_replace( ‘/[^0-9]+/’, ”, $MATCHES[1] );

$HOST[‘followers’] = $followers;

$UPDATES[] = “followers = “.intval( $followers );
}

$query = “UPDATE theticket_hosts SET “.join( ‘, ‘, $UPDATES ).” WHERE id = “.intval( $HOST[‘id’] ).” LIMIT 1 “;

mysql_query( $query ) or trigger_error( mysql_error(), E_USER_ERROR );
}

function curlIt ( $url )
{
$user_agent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0’; // ‘FireFox3’ (*11,12 type2- books.google.com)
// $user_agent = ‘Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204’; // ‘Linux Firefox’ (* 11,12,13 type2)
// $user_agent = ‘Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)’; // ‘IE7’
// $user_agent = ‘Mozilla/4.8 [en] (Windows NT 6.0; U)’; // ‘Netscape’
// $user_agent = ‘Opera/9.25 (Windows NT 6.0; U; en)’; // ‘Opera’ (*11,12,13 type2- google.com/products)
// $user_agent = ‘LW/1.0’;

$header = array
(
“Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5”,
“Cache-Control: max-age=0”,
“Connection: keep-alive”,
“Keep-Alive: 300”,
“Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7”,
“Accept-Language: en-us,en;q=0.5”,
“Pragma: “, // browsers keep this blank.
);

$ch = curl_init();

curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
curl_setopt( $ch, CURLOPT_ENCODING, ‘gzip,deflate’ );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt( $ch, CURLOPT_AUTOREFERER, 1 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );

curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent );

$returned = curl_exec( $ch );

if ( !( $curl_errno = curl_errno( $ch ) ) )
{
}
else
{
$returned = false;
}

curl_close( $ch );

return $returned;
}
?>

Visit The ORIGINAL Ticket


10 COMMENTS

  1. April 20, 2011 20:22 Reply

    Do you like things??

    • Human, Internets
      June 10, 2011 20:18 Reply

      I like lists.

  2. SnC
    June 11, 2011 03:47 Reply

    no TC?

  3. June 11, 2011 15:36 Reply

    I don’t do tickers by the way. I board op and produce Cirque. I do appreciate the mention though.

    • June 13, 2011 14:30 Reply

      sorry Mike…I know the names, but the actual gigs I was struggling with. There’s probably more I screwed up too, so feel free to fill me in on other mistakes

  4. June 12, 2011 00:20 Reply

    Looks like we missed one – Roy White, producer of The Soulpatch: http://twitter.com/RoyWhite1310

    Matt McClearin insists on calling him “the big boy toy full of joy”…sooo, how ’bout we just go with “Roy”.

Leave a reply