Now Tweeting with PHP is made easier by PEAR..
Will write a detailed post about PEAR library later, but for now I will just show you a simple example of writing a tweet to Twitter using PHP PEAR library.
You need to install the following PEAR libraries for the following code to work.
pear install Net_URL2-0.2.0
pear install HTTP_Request2-0.4.0
pear install Services_Twitter-0.3.0Here is the sample code in PHP for using twitter service...
<?php
require_once 'Services/Twitter.php'; $username = 'xxxxxxx'; $password = 'xxxxxxx'; try { $twitter = new Services_Twitter($username, $password); $msg = $twitter->statuses->update("I'm coding with PEAR right now!"); print_r($msg); } catch (Services_Twitter_Exception $e) { echo $e->getMessage(); } ?>
No comments:
Post a Comment