/ Published in: PHP
Thanks to James Padolsey for sharing this script with everyone on his blog, link above.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// (C) Copyright JAMES PADOLSEY class tweetFromFile { private $curlHandle; private $updateFile; private $archiveFile; private function getNewStatus() { $upcomingTweetsFile = $this->files['upcoming']; $archivedTweetsFile = $this->files['archive']; // Get upcoming Tweets: // ARCHIVE OLD POSTS: // Remove top line from upcoming: // Clean up return $splitContents[0]; } public function __construct($username, $password, $filename) { $this->files['upcoming'] = $filename; $this->files['archive'] = 'ARCHIVE_' . $filename; // Shortcut: $ch = $this->curlHandle; } public function __destruct() { } public function updateStatus() { $status = $this->getNewStatus(); if ($resultArray['http_code'] == 200) return true; return false; } } // ================== // ===== USAGE ====== // ================== $tweet = new tweetFromFile('twitterUsername', 'password', 'textfile.txt'); $success = $tweet->updateStatus(); if ($success) { echo 'Twitter updated!'; } else { echo 'Hmm, an error...'; }
URL: http://james.padolsey.com/twitter/tweetfromfile-php-class/