Services_Twitter
Important
This project is now an official PEAR package and has moved to PEAR repository. Please report all bugs using the PEAR Bugtracker.
About
Services_Twitter is a PHP PEAR package for interfacing with Twitter's API. Specifically, it's an interface for the HTTP-Auth API and not the Jabber API.
Installation
- Install PEAR if it is not already installed on your system.
- Run pear install Services_Twitter.
Example
Updating Status
<?php
require_once 'Services/Twitter.php';
$user = 'YourUsername';
$pass = 'YourPassword';
$update = '@joestump ' . $user . ' is playing with Services_Twitter.';
try {
$twitter = new Services_Twitter($user, $pass);
$res = $twitter->statuses->update($update);
} catch (Services_Twitter_Exception $e) {
echo $e; // Services_Twitter_Exception::__toString() outputs a message
}
?>Get User Info
<?php
require_once 'Services/Twitter.php';
$user = 'YourUsername';
$pass = 'YourPassword';
try {
$twitter = new Services_Twitter($user, $pass);
// Get foo's information
$res = $twitter->users->show('foo');
print_r($res);
// Get foo's information using foo's email address
$res = $twitter->users->show('foo@example.com');
print_r($res);
} catch (Services_Twitter_Exception $e) {
echo $e; // Services_Twitter_Exception::__toString() outputs a message
}
?>