HTML Code to Update Twitter

Posted on 2011-10-24
Last Modified: 2013-11-14
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>

Question by:theabbeyschool

    Author Comment

    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

    LVL 70

    Accepted Solution

    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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Lets start to have a small explanation what is VAAI(vStorage API for Array Integration ) and what are the benefits using it. VAAI is an API framework in VMware that enable some Storage tasks. It first presented in ESXi 4.1, but only after 5.x sup…
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
    This Micro Tutorial will teach you how to reformat your flash drive. Sometimes your flash drive may have issues carrying files so this will completely restore it to manufacturing settings. Make sure to backup all files before reformatting. This w…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now