Proper Twitter Integration with Zend Framework
Twitter is all the rage these days. Every site out there has some kind of "Tweet This" link or "Follow us on Twitter" button. Some sites have even deeper integration and tweet events on your behalf. In most cases, those sites are asking you for your Twitter username and password. What? Even scarier, many people enter their credentials without thinking twice. It's crazy. When has it become acceptable to enter your credentials for your online accounts (that often make you choose six or more character passwords) into some random third party site? Well, the answer, I suppose, is since social networking sites have began asking for email account access to rummage through your contact list. Still, it's a rather unacceptable solution for a self-respecting web site to operate this way, especially since Twitter supports the OAuth protocol which is designed to tackle this exact problem.
If you're familiar with how Flickr allows third-party applications and websites access to your account, then you know how it works. A web site requests access to your account, you are prompted to allow and deny access, and that's it. There are no passwords involved. And if you decide that you don't like what that website is doing with your account, you can revoke access at any time.
I will assume that you're already familiar with the Zend Framework. If that is not the case, and you're a PHP developer, you should really consider starting to use it. It is a very well designed and powerful collection of classes that complement each other and, after the initial ramp up time and learning curve, will pay off in both terms of development speed as well as maintainability. Check out the Quick Start.
In fact, Zend Framework (1.8) ships with a Zend_Service_Twitter class, which provides all the Twitter functionality. The problem is that this class only supports Basic Authentication using your Twitter account username and password. But fear not, we can bend this class to do our bidding.
See, underneath the hood, Zend_Service_Twitter is actually a Zend_Rest_Client, which is powered by Zend_Http_Client. Let's just remember that for now.
Let's take a look at this OAuth thing. Zend Framework has some preliminary support for it in the incubator. The client portion of it is functional, although kind of buggy, still.
The proposal for Zend_Oauth can be found here http://framework.zend.com/wiki/pages/viewpage.action?pageId=37957, complete with a ma.gnolia.com example use case.
Let me summarize how this works real quick:
1. Your configured Zend_Oauth_Consumer fetches a request token, which is used to prompt the user of the service to allow access.
2. Once access is allowed, your application receives an access token.
3. Your can ask the access token object to hand you an http client. It's a Zend_Oauth_Client, which extends Zend_Http_Client, and automagically handles the signing so you can treat it like a regular Zend_Http_Client and perform all the GETS and POSTS you want. Nifty!
Now let's go back to the Zend_Service_Twitter. Remember how it uses a Zend_Http_Client? All we have to do now is remove the basic (username/password) authentication mechanism and replace it with the OAuth-based version. To achieve that, we'll simply extend Zend_Service_Twitter as My_Service_Twitter. and make the following changes:
class My_Service_Twitter extends Zend_Service_Twitter
{
/**
* @var array
*/
protected $_oauthOptions;
/**
* @var Zend_Oauth_Token_Access
*/
protected $_accessToken;
/**
* Initialize Oauth
*/
protected function _init()
{
if (!$this->_authInitialized) {
$client = $this->_accessToken->getHttpClient($this->_oauthOptions);
$client->setHeaders('Accept-Charset', 'ISO-8859-1,utf-8');
self::setHttpClient($client);
$this->_authInitialized = true;
}
$client = self::getHttpClient();
$client->resetParameters();
}
/**
* @param array $oauthOptions
* @return My_Service_Twitter provides fluent interface
*/
public function setOauthOptions(array $oauthOptions)
{
$this->_oauthOptions = $oauthOptions;
return $this;
}
/**
* @return array
*/
public function getOauthOptions()
{
return $this->_oauthOptions;
}
/**
* @param Zend_Oauth_Token_Access $token
* @return My_Service_Twitter provides fluent interface
*/
public function setToken(Zend_Oauth_Token_Access $token)
{
$this->_accessToken = $token;
return $this;
}
/**
* @return Zend_Oauth_Token_Access
*/
public function getToken()
{
return $this->_accessToken;
}
}
And it's ready to be used. Instantiate the class, set the Oauth token via setToken() and then use the class the same way as before.
Print This Post
NBC17 News engages audience with Twitter

Twitter on NBC17
In what may be a TV station's first, NBC17 is using Twitter to gather feedback from the local community in the greater Raleigh, NC area. I was fortunate enough to be included in this experiment, although I was unaware how my tweets were going to be used.
@MyNC, mync.com's twitter presence, asked about pay as you go (PAYG) cellphone plans. Some of @MyNC's Twitter followers responded with their experiences and suggestions. The responses were not just casually included in their report, but specifically called out and highlighted on the air.
All in all, this is a bigger deal than it may seem at first. TV stations are realizing that embracing the near instantaneous interactivity that social media users are enjoying is an important step in preventing their own irrelevancy. By targeting the younger always-online audience and taking advantage of social media tools such as Twitter and Facebook, traditional media is not only proving their ability to adapt to new technologies, but it could very well rekindle interest to watch the evening news in the next generation of viewers wanting to see their own messages featured.
Additional benefits for TV stations to embrace tools such as Twitter, Qik, etc. is the ability to reduce response times to local key events and augmenting their reports in cost effective ways.
Print This Post
Spokeo is kind of Scaryo
Evidently 2008 is the year of the aggregators. They're everywhere. Socialthing, ping.fm, and what have you. But here's one with an immedialy obvious business model. Introducing Spokeo. An aggregator that asks you to provide your AOL, Gmail, Hotmail or Yahoo email credentials (which, in my opinion isn't the safest way to share contacts and I wouldn't divulge that kind of information) to load all your contacts from your address book and then tries to connect all the dots.
Spokeo advertises that individuals who give up their email account credentials can find out "secrets" about their friends. The same information that's available free to individuals (well, subsidized by allowing Spokeo to harvest your contact list) is also sold to anyone who'll pay for it. Specifically, they're targeting HR departments.
Their business model is providing in a way, a social media-based public information "background check" to companies. And that's probably a very appealing thing to Old Economy Mega Bank Corp. which will use this service to see what potential job candidates have been up to on 43 Things, Amazon, Bebo, Blogger, Buzznet, dailymotion, deviantART, Digg, Facebook, Flickr, Flixter, Fotolog, Friendster, Hi5, iLike, imeem, Last.fm, LinkedIn, LiveJournal, Multiply, MySpace, Netlog, Pandora, PhotoBucket, Picasa, PictureTrail, Slide, StumbleUpon, Twitter, Upcoming, Veoh, Vox, Web Results, WebShots, Windows Live Spaces, Wretch, Xanga, Yelp, and YouTube.
So, if work hard and play hard, make sure what happens in Vegas stays in Vegas.
Print This Post
Comcast reads blogs, provides customer service through Twitter
More and more companies are starting to embrace the social web. Comcast discovered that communicating and following up with unsatisfied customers through third party web sites (personal blogs, Twitter, etc) can have a positive effect.
Of course, that's a Good Thing™, because as a (due to lack of alternatives, sometimes forced) customer it often seems that one is interacting with a large, faceless corporation that appears to care only about taking your money, and if you're lucky, providing just enough service to you in return that it's not worth the hassle of trying to complain to them directly.
Comcast's new approach will certainly help to remind everyone that even large companies consist of real people that get up in the morning, go to work and, for the most part, work hard every day. Of course, just because they decide to dedicate some of their staff to scour the Internet for frustrated customers doesn't necessarily mean their internal business processes or policies will improve, but hey, it's a start. And in this case it seems that Frank Eliason, digital care manager at Comcast, is the person who spearheaded this new effort.
Print This Post
itsourtree.com - Social Network for Your Whole Family
Ever been wanting to map out your family tree in an intuitive format and work on it collaboratively with other family members? Check out itsourtree.com, which is essentially a social network site for your extended family.
So far I've found genealogy software to be quite clumsy, but Hamburg, Germany based OSN Online Social Networking GmbH has build a pretty solid foundation for making family trees intuitive and fun.
With my family being spread across (at least) two continents, it's actually helped get back in touch with some of the folks that I haven't seen in years.
The approach taken here is quite interesting as it allows one to add a person to the family tree, enter their email address to invite them and let them modify the tree. The result is a recursive chain reaction of spouses adding their side of the family.
Just a few weeks ago my mom and I talked about our family history. I find it interesting to know where I came from and its quite exciting, like a little treasure hunt, to try to follow leads and discover potential new distant relatives. And it also just makes sense to know a little bit about your ancestors' medical history for the benefit of your own health.
Luckily, my mom's dad has a relatively rare last name (the map to the right is a distribution of known people in Germany with that last name, and there aren't that many even today). Armed with that, few family records, and my mom's wits and ingenuity, she was able to dig up quite a bit of information. Using sites such as FamilySearch.org, ellisislandrecords.org, and random bits of information revealed through various search engines, we've found records reaching all the way back to the 17th century (a wedding record from 1696).
She told me about a ship, the John Bertram, and sent me the ship's passenger manifest that apparently carried some of our ancestors (a couple aged 58 and 62) from Hamburg, Germany to New York in 1866. A Google search for "John Bertram" turned up a random geocities page with more information about the ship.
The U.S., later Hamburg, ship JOHN BERTRAM was built as an "extreme clipper" at East Boston, by Ewell & Jackson, in the short time of 61 days, and launched on 9 December 1850. She was built under the supervision of Capt. Glidden for the Glidden & Williams Line of Boston-San Francisco packets, and was owned jointly by Glidden & Williams, of Boston, and Flint, Peabody & Co, of San Francisco. She was named after the well-known Salem sea captain and merchant, John Bertram. 1,080/778 tons (old/new measurement); 173/180/190 x 37 x 20 feet(keel/deck/overall length x beam x depth of hold); her figurehead was a representation of an eagle on the wing, and on her stern was a medallion bust of her namesake.
Excuse me for a minute while my mind imagines an epic motion picture style flashback to 1866 where the farmers couple Johann (58) and Maria Lubsch (62) venture on a months-long journey, presumably leaving behind most of their belongings (how do you pack up a farm?), and possibly fight fierce weather conditions on their way to the New World. It's not like it was a Disney Cruise. And I'm guessing they didn't call ahead to make hotel reservations, considering Graham Bell didn't speak into his first phone roughly ten years later on March 10, 1876.
We have yet to figure out exactly what happened to this couple. Why did they leave? Where did they go? Did they have kids? (hint: she probably didn't, but he might have). We don't know, and while itsourtree.com isn't going to answer those questions either, it's encouraged and helped us organize our family history.
Print This Post
Categories
- Database
- Development
- Entertainment
- Gaming
- Hardware
- PHP
- Second Life
- Social Web
- Software & Tools
- Uncategorized
- Virtual Worlds
- Zend Framework
Archives
- May 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- June 2010
- May 2010
- March 2010
- February 2010
- January 2010
- December 2009
- October 2009
- August 2009
- July 2009
- May 2009
- April 2009
- March 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- February 2008
- December 2007
- August 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- March 2006
- January 2006
- December 2005
- November 2005
- October 2005
- June 2005
- March 2005
- February 2005
- December 2004
- November 2004
- September 2004
- August 2004
- July 2004
- March 2004


