Check out the Latest Articles:

RealTime Twitter Logging – Social Media Tutorial

RealTime Twitter Logging – Social Media Tutorial

Using Twitter API to generate systems that are useful is very easy. It takes little code, and little time to implement. I cannot stress enough how easy (for a developer) using Twitter API is. Anyone can easily create interesting services with Twitter’s API. The only problem is that these services have to rely on Twitter for their business model, and Twitter is Free. Eventually Twitter will not exist. Free business models based on 3rd party services are not sustainable. The Freemium model is dying a slow and painful death. The shift into premium only business models is a new trend. Like most technology trends, early adopters set the stage for the entire community. Soon this trend will boom and nothing will be free. Luckily for our users, the one guarantee we make is that our product will never be free.

Introduction:

Most events assign special #tags to their tweets so they can track / search for the most up to date activity during their event or get together. Twitter clients such as TweetDeck have utilized this search functionality very well.

After becoming curator for The Startup Digest London, I realized the importance of these #tags. Yet I feel that they are not being utilized to their full potential, which is what led me to this tutorial.

The Problem:

Typcially, #tags are used for twitter searches. This works very well, but doesn’t allow us to separate a current event from a past event using the same #tag. This tutorial is intended for those who’d like to create archives based on specific #tags for specific events.

I will go over the basic setup in the backend and the necessary Twitter API functionality needed to make it all happen. I will not discuss integration specific coding or technologies. The tutorial will be very general and display the theoretical system with sample code and explanation.

The concept of the tutorial is to log and organize tweets based on a #tag and the post date for later display. The goal being an event activity archive using the Twitter API.

Server Side Functionality:

On the server end of things we need a way to store and access the tweets that we log. Some sort of database will be necessary for this.

A simple class to manage the storage of data might look something like this:

require_once("database_connect.php");
 
class MyTweetStorage
{
 
	var $dbc; // database connection
 
	function MyTweetStorage()
	{
 
		// grab the mysql connection from the included constant
 
		$ths->dbc = DATABASE_CONNECTION; 
 
	}
 
	function logTweet( $tweet, $date, $hashtag )
	{
 
		// insert into database
 
		$q = "insert query for tweet";
 
		$r = {insert into database};
 
		return {TRUE or FALSE};
 
	}
 
	function getTweets( $date, $hashTag )
	{
 
		// insert into database
 
		$q = "get tweets for $date with $hashtags";
 
		$r = {get from database};
 
		return {results in an Array};
 
	}
 
}

That is a very simplified version of what the server side might look like. The above shell needs a lot more code in order to be functional, but I am merely demonstrating proof of concept.

Twitter API Connection:

I will not get into the code here, but the calls to Twitter will be along the lines of a search. The system will need to pull all the tweets for a specific event based on the date of the event and the #tag used to represent that event. So, if we were to use #sdlondon for The Startup Digest London, and we were at an imaginary event tagged #event on Dec. 15 2010, our search query to twitter would look for those hash tags in tweets that were posted on that day. Such a concise query is required to limit the number of tweets we will filter from Twitter’s stream.

Once we have the list of available tweets from our query, we use the above code to insert them in the database. Then, anytime someone comes to the site and wants to see a log of that event, we can display the list for that specific event. Using this data, the visitor can see if the event is worthwhile.

So very simple. So very free.

Share:
  • Digg
  • Facebook
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • MySpace
  • Posterous
  • Tumblr
  • del.icio.us
  • FriendFeed
  • Reddit
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Twitter
  • Live
  • PDF
  • Ping.fm
  • Simpy
  • Yahoo! Bookmarks
  • Yahoo! Buzz

  • click down
    the above information is extremly essential……Thanks for the info!
    They look really good! I love changing my background around a lot!

    twitter tutorial
blog comments powered by Disqus