Twitter and zend framework

# twitter_index.php

/**
* This code shall update the twitter-status when a new graphic is posted
* It will be using the Zend Framework
*/
$path = ‘/Zend/library/’;
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
include “Zend/Service/Twitter.php”;
# include “Rest/client.php”;

# Connect to the twitter-service
try {
$twitter = new Zend_Service_Twitter(‘username’, ‘password’);

echo “that’s nice
\n”;
echo “Followers: “.$twitter->userFollowers();

# verify your credentials with twitter
$response = $twitter->accountVerifyCredentials();

# Here you should add:
echo $response->error;

echo “That’s great!”.$response.”
\n”;

# echo “StatusShow: “.$twitter->statusShow($response).”\n”;
echo “status: “.$twitter->status->friendsTimeline().”\n”;

$response = $twitter->status->userTimeline();
$twitterstatus = (string)$response->status[0]->text;
echo “twitterstatus: “.$twitterstatus.”\n”;

echo “timeline: “.$twitter->status->UserTimeline().”\n”;

$response = $twitter->status->update(‘My Great Tweet-from PHP’);
} catch (exception $e) {
echo “That’s odd
\n”;
echo $e;
exit();
} catch (Zend_Service_Twitter_Exception $t){
echo “Hello there!
\n”;
echo $t;
exit();
}

?>

Fixed: I had the wrong password.

You can leave a response, or trackback from your own site.

Leave a Reply