HTML Code to Update Twitter

Hi, I have the code below that I have found on the Internet. Unfortunately it doesn't work, does anyone know how I can update it to make it work and authenticate with Twitter?


<form action="" method="POST" enctype="application/x-www-form-urlencoded">   <!-- set your Twitter username and password here --><input type="hidden" name="user" value="{ TWITTER USERNAME }" /> <input type="hidden" name="pswd" value="{ TWITTER PASSWORD }" />   status <input type="text" name="status" maxlength="140" /> <input type="submit" value=" tweet! " /> </form>

theabbeyschoolNetwork ManagerAsked:
Who is Participating?
Jason C. LevineNo oneCommented:
That code is really old and twitter no longer supports updating through that method.

In order to update Twitter, you have to use OAuth and the Twitter API
theabbeyschoolNetwork ManagerAuthor Commented:
I've also tried this code but it has the same problem, it cannot authenticate:


     <title>VbScript Tweets - Update your Twitter status</title> 


     <style type="text/css"> 
     /* General styles */ 
     body     {      
          margin: 0px; 
          padding: 0px; 

     /* format specific */      

     #header { 
          border-bottom: 1px solid #000000; 
          padding: 10px; 
          font-family: verdana, arial, helvetica, sans-serif; 
          font-size: 10px; 

          padding: 20px; 
          font-family: verdana, arial, helvetica, sans-serif; 
          font-size: 20px; 

     #inputboxed { 
          font-family: verdana, arial, helvetica, sans-serif; 
          font-size: 20px; 
          font-weight: bold; 
          background-color: #F3F3F3; 

     #twitterresponse { 
          padding: 10px; 
          font-family: verdana, arial, helvetica, sans-serif; 
          font-size: 10px; 
          text-align: center; 
     .vbtweetstd { 
          vertical-align: text-top; 
          font-family: verdana, arial, helvetica, sans-serif; 
          font-size: 10px; 
     .buttonclass { 
          font-family: verdana, arial, helvetica, sans-serif; 
          font-size: 12px; 
          font-weight: bold; 
          border: 1px solid #000000; 
          width: 200px; 
          height: 50px; 
          background-color: c6e2ee; 


<script language="vbscript"> 

     OPTION EXPLICIT 'Be sure you have al your variables declared. 

     ' SETTINGS 
     ' The below values are the only values you have to change to get this script working 

     Const conUsername = "Twitter username" ' Your Twitter username 
     Const conPassword = "Twitter password" ' Your Twitter password 

     Sub DoTwitter 
          ' This sub is built in to perform some checks 
          Dim strTwitterMessage 
          strTwitterMessage = TxtTwitter.value 
          If Len(strTwitterMessage) > 140 Then 
               ' In case you message is too long, it drops a warning.. 
               twitterresponse.InnerHTML = "Your message is more then 140 characters, Twitter will post it, "& _ 
                    "but your followers have to click on your message to read the entire story. " & _ 
                    "It is recommended to make your message shorter then 140 characters...<br /><br /><br />" & _ 
                    "To continue anyway, click yes, otherwise change your message and click the &quot;Send to twitter&quot; button again.<br /><br />" & _ 
                    "<input class=""buttonclass"" type=""button"" value=""Yes... (please continue!)"" OnClick=""SendToTwitter"" />" 
          ElseIf Len(strTwitterMessage) = 0 Then 
               ' In case you did not enter a message at all... 
               twitterresponse.InnerHTML = "You did not enter a message..." 
               ' Otherwise, call the sub to post your message to Twitter 
          End If 

     End Sub 

     Sub SendToTwitter      

          ' This is the function wicht does all the work. 
          ' It uses XMLHTTP to post your message to Twitter.. 
          Dim objHTTP , strSendToTwitter 
          Set objHTTP = CreateObject("Microsoft.XMLHTTP") 
      "POST", "", false, conUsername, conPassword 
               objHTTP.send "status=" & TxtTwitter.value & " test.."           
               ' The function stores the Twitter response to a variable so you can use that response later 
               strSendToTwitter = objHTTP.responseText 
          Set objHTTP = nothing 'Release the object 
          ' Now do something with the result. It's not 
          ' necessary for the script to work, but it is nice to use it later 
     End Sub 

     Sub ReadXMLFile(strXML) 
          ' This sub make the XML response readable. 
          ' it formats the XML into a table layout, but you can 
          ' easily change this to a more advanced solution like 
          ' a logfile or something. 
          Dim xmlDoc 
          Set xmlDoc = CreateObject("Microsoft.XMLDOM") 
          xmlDoc.loadXML strXML 
          Dim strMessage 
          strMessage = "<table border=""0"">" 
          ' Perform a loop through all the childnodes 
          Dim x 
          For Each x In xmlDoc.documentElement.childNodes 

               strMessage = strMessage & "<tr><td class=""vbtweetstd""><b>" & x.nodename & "</b></td><td class=""vbtweetstd"">: </td><td class=""vbtweetstd"">" & x.text & "&nbsp;</td></tr>" & VbCrlf 
          Set xmlDoc = nothing ' Release the object 
          ' Close the table 
          strMessage = strMessage & "</table>" 
          ' Drop the formatted HTML table into the message area.. 
          ' It is still some pretty rough output a user can't do anything with, 
          ' but I don't want to make the code too long.. 
          twitterresponse.InnerHTML = "<strong>Twitter responded:</strong><br /><br /><br />" & strMessage 
     End Sub 

     Sub CountCharacters 
          ' Show how many characters are used so far. 
          ' This sub is called each time you release a keyboard button. 
          twitterresponse.InnerHTML = Len(TxtTwitter.value) & " characters used.." 
     End Sub 



<!-- Start Header, modify or delete as you like! --> 
<div id="header"> 

     <strong>SITEJUNCTION</strong><br /> 
     <small>TWITTER STATUS UPDATE</small> 
     <br /><br /> 
     With this hta script you can update your Twitter status <br /> 
     more info: <a href="" target="_blank"></a> 
<!-- End Header --> 

<!-- Start Twitter message box--> 
<div id="twitterboxarea"> 

     Enter your Twitter message in the box below; 
     <br /><br /> 
     <input type="text" id="inputboxed" size="50" name="TxtTwitter" OnKeyUp="CountCharacters" maxlength="400" /><br /><br /> 
     <input class="buttonclass" type="button" onclick="DoTwitter" value="Send to Twitter.." /><br /><br /> 
<!-- End Twitter message box--> 

<!-- Messages appear here--> 
<div id="twitterresponse"></div> 
<!-- End of Messages box --> 


Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.