Searching Twitter for America's National Pastime
What is this?
A realtime list of recent tweets that mention various Major League Baseball teams that automatically refreshes ever 30 seconds. By default, this searches for any any tweet that mentions one of the official Twitter accounts for an MLB team. There are additional options to filter by team and the script will search for mentions of the team, and in some cases certain players (e.g., Hunter Pence on the Giants and Yasiel Puig on the Dodgers).
If you want to run and host this yourself, you’ll need a server capable of running PHP (this is used to authenticate with the Twitter API and parse the search results into usable JSON.
You’ll also need to enter your Twitter API token and key in order to search tweets. You can enter these credentials in the following file: /php/search.php
Why did you do this?
Libraries and frameworks used
- Skeleton - Used as a responsive boilerplate to rapidly build out the site and make sure it worked on both desktop and mobile devices.
- bbclub-font - An open source project that displays scalable team logos from all 30 MLB teams.
- jPushMenu - jQuery plugin to easily add the side menu that slides in from the left and allows users to choose a proper team.
- Livestamp.js - jQuery plugin to provide auto-updating time ago text (e.g., posted 5 minutes ago)
- Moment.js - Parse, validate, manipulate, and display dates that were returned from the Twitter API.
- TwitterOAuth - Validate your developer token with Twitter and access its API through PHP.
Other helpful sources: