Though I personally loathe twitter because of the distraction it breeds, it has a very powerful API which allows developers to create cool apps like twhirl or tweetdeck. Here is one that runs in a browser.
Background:
The client has a website built on a Drupal 6 platform and needs users to be able to tweet to their account from his Website. The tweet box on his Web site has a sports hashtag already entered into the tweetbox, and entries with that hashtag will flow through the real-time stream of that sports category. The real time twitter stream is shown to the left of the tweet box on the homepage of the site, so users can see their tweet go through the twitter river in fairly short order.
I tried a few drupal modules, but they just aren't there yet to both allow users to sign in from twitter AND tweet from the drupal site. The twitter 6.x-3.x module is still in development and I don't know enough about module development to try to offer a patch to make it work for this purpose. This module does allow you to sign in with twitter, but I was unsuccessful in getting a tweet to post using it. The official release, 6.x-2.6 doesn't have oauth support, so that isn't possible for this task.
Application overview:
This application leverages a PHP code library developed by Jaison Mathai. In fact the library pretty much is the app, with a few tweaks for my own purposes.
The application uses oauth to let twitter handle all of the login and authentication stuff, so users don't have to enter in their password to anyone but twitter. Twitter then sends back a token to requesting website, which then sets a cookie in the user's browser. The user, with cookie stored now, can now tweet in the box on the site. No passwords are ever stored - just an authentication token that expires after you log out of twitter.
For more on the behavior and security of oauth, read about it here.
Here is the very cool code library I used.
Demonstration
If you'd like to test this out how it works, go ahead and authenticate my site by signing in with Twitter
.
Once that's done, you can tweet into this box here:
Extending the Application?
The Drupal twitter module is very powerful and hooks into the core user module to create a user account for someone signing into the drupal site using twitter sign in. However, what if you don't need or want to create a user account from every authorization? What if the goal is simply to allow users to tweet and not create an account on your site?
I just picked up a copy of Pro Drupal Development, and I'm finding it very resourceful and full of great knowledge. I have yet to wrap my head around building modules for Drupal and perhaps this would be a good exercise to turn this application into a plug-and-play module, even if it isn't committed back to drupal.org.


Comments
Hi, how do I implement the
Hi, how do I implement the "sent tweet" box?
I can't find the code for it or sample.
Also what are the variables to replace "via API" with custom url?
Thanks!