Yes we can.
Create a first static page for your eyes only call sendTwitterMsg (ID) and change username and password in code
Text Formatted Code
function postToTwitter($username,$password,$message){
$host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);
if($resultArray['http_code'] == "200"){
$twitter_status='Your message has been sended! <a href="http://twitter.com/'.$username.'">See your profile</a>';
} else {
$twitter_status="Error posting to Twitter. Retry";
}
return $twitter_status;
}
/* ---------------------------------------- */
// Change these parameters with your Twitter
// user name and Twitter password.
/* ---------------------------------------- */
$twitter_username ='username';
$twitter_psw ='password';
/* ---------------------------------------- */
/* Don't change the code belove
/* ---------------------------------------- */
if(isset($_POST['twitter_msg'])){
$twitter_message=$_POST['twitter_msg'];
if(strlen($twitter_message)<1){ $error=1; } else { $twitter_status=postToTwitter($twitter_username, $twitter_psw, $twitter_message); } }
/* ---------------------------------------- */
Then create a second static page still for your eyes only with this code and change url to point at your first page
Text Formatted Code
echo '<h2>Post a message on Twitter</h2>';
if(isset($_POST['twitter_msg']) && !isset($error)){
echo '<div class="msg"><?php echo $twitter_status ?></div>';
} else if(isset($error)){
echo '<div class="msg">Error: please insert a message!</div>';
}
echo '<p><strong>What are you doing?</strong></p>' .
'<form action="url_to_my_insertTwitterMsg_page" method="post">' .
'<input name="twitter_msg" type="text" id="twitter_msg" size="40" maxlength="140" />' .
'<input type="submit" name="button" id="button" value="post" />' .
'</form>';