August 28, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Integrating Twitter Into the Zend Framework

  • January 22, 2009
  • By W. Jason Gilmore
  • Send Email »
  • More Articles »

I'll admit I'm a rather late adopter of Twitter, the real-time short messaging service that has in recent months taken the tech community by storm, and has as of late seen adoption by organizations such as The Wall Street Journal, Dell, Whole Foods, and the Cleveland Plain Dealer (see twibs for a comprehensive business listing).

My interest in the service changed during the course of CodeMash, an annual developer's conference I co-founded. As it turns out, most of the CodeMash attendees are avid Twitter users, and were regularly posting thoughts regarding their experience attending the various sessions and other functions. Naturally, the organizers were very interested in these posts, using them as one of the barometers for gauging success. The easiest way to keep tabs on the posts was by way of Twitter's great search interface.

As it turns out, though, there are quite a few other ways to track Twitter trends, and even build your own interfaces for posting messages to your Twitter account, not to mention monitoring the posts of your friends. If you're looking for eye-candy, one of the most interesting applications is Twittervision, a mashup pinpointing the location of posting users. Tracking your post frequency is easy using TweetStats. Or, check out emotionally-inspired posts at twistori. View hundreds of other available Twitter-oriented applications at the Twitter Fan Wiki. All of these compelling solutions are possible using the fantastic set of Twitter APIs made available thanks to the Twitter team.

Using these APIs, a number of Twitter clients also have popped up. twhirl (see Figure 1) is probably the most notable example for desktop users, although iPhone and iPod clients are available, as are Google and Opera gadgets.



Click here for a larger image.

Figure 1: The twhirl Twitter Client

But, what if you wanted to create your own client, or integrate your Twitter stream into your blog or website? Indeed, if your main goal in starting a Twitter account is to post messages regarding a specific product, service, or organization, it might be most convenient to integrate an update mechanism into your existing content management system. Further, you might use Twitter's infrastructure as a solution for keeping your website visitors up to date regarding new features and other announcements by integrating the stream into your website's news page. Using the aforementioned APIs, the sky is really the limit in terms of what you can do! In this tutorial, I'll show you how I integrated the newly launched GameNomad Twitter companion into http://www.gamenomad.com/, creating a useful news feature without having to deal with creating an interface and database table solely for managing news-related posts.

Introducing Zend_Service_Twitter

The Zend_Framework's Zend_Service_Twitter component presents an easy solution for communicating with the Twitter infrastructure, offering the ability to log in to Twitter, retrieve and post messages, reply to friends, and interact with practically every other aspect of the Twitter service. In just minutes, I used this fantastic component to publish the latest posts from the GameNomad Twitter companion to http://gamenomad.com/news.

Figure 2: Integrating Twitter Into GameNomad

Integrating this feature into the GameNomad website took surprisingly little time. To begin, you'll need to update the config.ini file to include your Twitter account's username and password. If you don't already have a Twitter account, take a moment to do so; it's quick and easy.

Update the config.ini file

Always intent on centralizing all configuration parameters within the Zend Framework's config.ini file, the first task you should undertake is updating this file to include your Twitter account's username and password:

twitter.username = "gamenomad"
twitter.pswd     = "supersecret"

Be sure to save the file, and move on to the next step.


Tags: Twitter



Page 1 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel