channel->item->title); // check this status message against the one previously updated // make sure your file exists, and that it's readable/writable by the server $setMsg = "twitter.txt"; $fh = fopen($setMsg, 'r'); $data = fgets($fh); fclose($fh); // only update twitter if it's different if ($msg != $data) { /* inform twitter about something */ $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "http://twitter.com/statuses/update.xml"); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE); // change to FALSE for not reporting XML output curl_setopt( $ch, CURLOPT_POST, 1); curl_setopt( $ch, CURLOPT_POSTFIELDS, "status=" . urlencode( $msg)); curl_setopt( $ch, CURLOPT_USERPWD, "$username:$password"); ob_start(); $response = curl_exec( $ch); ob_end_clean(); curl_close( $ch); // check for success or failure if (empty($response)) { echo 'Error'; } else { echo '
Twitter status for ' . $username . ' updated:
' . $msg . '
Powered by Twitterbook
'; // update the status file with this message $setMsg = "twitter.txt"; $fh = fopen($setMsg, 'w') or die("can't open file"); fwrite($fh, $msg); fclose($fh); } } ?>