What’s the use of another twitter client, one may wonder?

These small scripts will be useful in a blog or any application which needs to interact with Twitter. You may want to let people to leave you a tweet instead of a message. I’m going to show you how to make it using PHP since most of you, readers, own blogs coded in PHP.

To make this baby, I’ll need to create a form, some scripts, and use Verkoyen’s BSD-licensed Twitter API. There are other more advanced APIs which work with the OAuth protocol out there but for the purpose of this small app, Verkoyen’s API is good enough. If you love programming, make your own API. It’s fun.

So, I’ll create a web form named “tizozote.php.” Zozote” is the “Kreol Morisien” equivalent of “to tweet as explained by @carrotmadman6.” “Ti Zozote” means “Small Tweet.”

tizozote.php will incl. the following:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Ti Zozote</title>

</head>

<body>

Now, I’ll write the scripts.  Functions.php will be coded later on. Add the following snippet to tizozote.php.


<?php

require_once('functions.php');

if (isset($_POST['posted']) && $_POST['posted'] == 'yes') {

echo "

Message: ".$_POST['tweet']."

";

echo "Wee Messaze la fine zozoter!

";

tweet($_POST['twitter_username'],$_POST['twitter_password'],$_POST['tweet']);

} else {

 echo "

*Adding the form*


<form action='tizozote.php' method='post'>

<p><label for='twitter_username'>To nom ta zozo:</label>

<input type='text' name='twitter_username' id='twitter_username' /></p>

 <p><label for='twitter_password'>Done to pass:</label>

 <input type='password' name='twitter_password' id='twitter_password' /></p>

 <p><label for='tweet'>Tape to zozote:</label>

 <textarea name='tweet' id='tweet' maxlength='140'></textarea></p>

 <input type='submit' value='Zozote'/>

 <input type='hidden' name='posted' id='posted' value='yes' />

</form>

 ";

}

?>

</body>

</html>

Now, I’ll code functions.php (you can change the file names. I like to use that name.)

functions.php will bear the following codes:


<?php

 require_once('twitter.php');

function tweet($u,$p,$msg) {

 $twitter = new Twitter($u ,$p);

 $twitter->updateStatus($msg);

 }

?>

Place tizozote.php and functions.php in the same folder.

Download the API file – twitter.php (extract the zip file) – it should also be placed in the same folder on your web server (e.g Apache.)

Fire up the URL of tizozote.php in your web browser.

Download TiZozote scripts – tizozote.zip (quick n’ dirty v.1.0)

Note: As seen above, the labels are in Kreol Morisien.

” > Username

> Password

“Tape to zozote:”> Enter your tweet.

Note: Tweak TiZozote to fit your needs. Have fun, tweeps. :)

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Fark
  • FriendFeed
  • MySpace
  • Slashdot
  • Tumblr
  • Twitter
  • Yahoo! Buzz
  • blogmarks
  • Live
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati