Hey Folks,
I have written a complete class which sends tweet and performs other stuff on twitter from following user to deleting Direct messages etc. But its just that I am not able to post the whole class here and explain it. I am gonna release a beta version of the class pretty soon with complete documentation, demoing and examples. Till then stay tuned and have a look at this simple script to connect to twitter API and send updates.
Just download the twitter class file and include it in your PHP script. Please note that you have to save the file as php file to include it in your php script file. I have kept the name twitter.inc.php for this example. You can give any name to the file but the class name should remain the same as twitter, as long as you do not change the contents of the file. This is going to be very basic class just to show you how to talk to twitter
The syntax to send the tweet using the above class file is as follows.
<?php //Download class from http://www.digimantra.com/resources/twitter.txt require_once("twitter.inc.php"); $credit=array(0=>"username",1=>"password"); //replace it with your username and password $t=new twitter($credit); //$t->set_debug(); // uncomment if you need to debug your script, incase of any Error, when your tweet is not being updated. $t->tweet("My First message from http://www.digimantra.com"); //pass tweet as an argument to tweet function $t->output(true); //pass true if you want browser to show the output , leave it blank if you want it to return the output instead. ?>
TODO:
Validation for the 140 character limit.
Sanitizing user input including username and password.
Probably implementing OAUTH
Will release the complete class pretty soon. Till then, stay beautiful
Cheers!!
Realin !







[...] get to know that “When did she joined twitter?”. I had built this functionality in my twitterapi class, so i created a tool to grab details when a particular user joined [...]
Very useful. I will integrate it in to my site.
Thanks
hmm.. interesting. I will try it out once I get this stupid IIS working on my win7. Mac is so much more easier!!
[...] have already learnt “How to update your twitter status ?” and also learnt how to interact with twitpic API to successfully upload images. Today I am [...]
Bonjour, Charming to join you, I am alise