24Oct/090
Update Twitter From Your Website (HTML form)
Here is a small script that allows you to post updates to twitter from a simple HTML form on your website.
First thing you need is the form, this is a simple HTML form, very easy to add to your existing website:
<form name="form1" method="post" action="twitter.php">
Now for the script, just copy and paste this code into a blank document and save as twitter.php, you can name it what you want just remember to change the form action variable:
$username = ($_POST['t_user']);
$password = ($_POST['t_pass']);
$message = ($_POST['t_update']);
$url = 'http://twitter.com/statuses/update.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer)) {
echo 'message';
} else {
echo 'success';
}
And that is it, if you want to set the username and password then all you need to do is change:
$username = ($_POST['t_user']); $password = ($_POST['t_pass']); // to $username = 'yourusername'; $password = 'yourpassword';
|
|
download: Web To Twitter (957B) added: 24/10/2009 clicks: 83 description: Post updates to Twitter from your website (Script) |

