Every web developer in this universe would like to have a Twitter application on his website. Here is the simplest possible PHP application that allows you to update your Twiter status from your webpage only. The script is extremely simple to use.
Before running the script you have to enable curl service in your PHP installation.
cURL stands for Client for URLs. It allows us to transfer files having URL syntax. It supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE.
To enable curl library with XAMPP we need to modify the php.ini files in our xampp folder.
1) Locate the following files:
C:Program Filesxamppapachebinphp.ini
C:Program Filesxamppphpphp.ini
C:Program Filesxamppphpphp4php.ini
2) Uncomment the following line on your php.ini file by removing the semicolon.
;extension=php_curl.dll
3) Restart your apache server.
4) Check your phpinfo if curl was properly enabled.
Just checkout the live demo…
<?php
/* ---------------------------------------- */
// Change these parameters with your Twitter
// user name and Twitter password.
/* ---------------------------------------- */
$twitter_username =$_POST['twitter_username'];
$twitter_psw =$_POST['twitter_psw'];
/* ---------------------------------------- */
/* Don't change the code belove
/* ---------------------------------------- */
require('twitterAPI.php');
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);
}
}
/* ---------------------------------------- */
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Webspeaks.in</title>
</head>
<body style="text-align:center; ">
<h2>Post a message on Twitter</h2>
<!-- This is the form that you can reuse in your site -->
<?php if(isset($_POST['twitter_msg']) && !isset($error)){?>
<div class="msg"><?php echo $twitter_status ?></div>
<?php } else if(isset($error)){?>
<div class="msg">Error: please insert a message!</div>
<?php }?>
<form action="insertTwitterMsg.php" method="post">
<label>Twitter Username : </label><input type="text" name="twitter_username"><br />
<label>Twitter Password : </label><input type="password" name="twitter_psw"><br />
<div style="background-color:#ffcccc;" ><p style="color:#FF0000; font-size:10px;">Your login details are not stored! Feel safe.</p></div>
<p><strong>What's happening?</strong></p>
<textarea name="twitter_msg" id="twitter_msg"></textarea><br />
<input type="submit" name="button" id="button" value="post" />
</form>
<!-- END -->
</body>
</html>
CSS Code
body{font-family:'Lucida Grande', Verdana, sans-serif;; font-size:14px; color:#666666; width:500px;}
div.msg{background:#FFFFCC; margin-bottom:10px; padding:4px;}
input{border:1px solid #2BAE9E; color:#444444; padding:3px; font-family:Georgia, "Times New Roman", Times, serif; -moz-border-radius:6px;}
#twitter_msg{border:1px solid #2BAE9E; color:#444444; padding:3px; font-family:Georgia, "Times New Roman", Times, serif; height:40px; width:400px; -moz-border-radius:6px;}
#button{background-color:#C8F0EF; border:2px solid #2BAE9E; padding:3px; -moz-border-radius:6px; float:right; margin:5px 45px 5px 5px;}
Fast and easy way to update status in twitter with PHP in 2 steps – http://ayauho.com/~ay
When some one searches for his vital thing, so he/she
needs to be available that in detail, thus that thing is maintained over here.
This article is in fact a nice one it helps new web users, who are wishing for blogging.