Announcement

Collapse
No announcement yet.

Using wget to send to Twitter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using wget to send to Twitter

    I have been trying to write a script that will send updates to Twitter so that my wife and I can easily check on the house when we are away. I have managed to create a batch file that does the job using wget, however, it all falls apart in the HomeSeer script:

    Code:
    sub main()
    
    hs.launch "C:\Program Files\HomeSeer\wget.exe","wget --keep-session-cookies --http-user=name@email.com --http-password=mypassword --post-data="status=This is a test tweet from HomeSeer." http://twitter.com:80/statuses/update.xml"
    
    end sub
    The script returns a "1025:Expected end of statement" error. I'm guessing it's because of the quotes inside the parameters. Any Ideas?

    #2
    Any replies?

    Hi, Igor3, Rob Rice here.

    I am also interested in using Twitter to broadcast updates from HS and also as a means of sending commands to HS. I have set up a Twitter account for the HS machine to use, but have no expertise in the use of wget.exe!

    Have you had any replies to your request for info so far?

    Comment


      #3
      From what little I know you can't put a set of quotes within a set of quote, it confuses the scripting engine.

      Try:
      PHP Code:
      hs.launch "C:\Program Files\HomeSeer\wget.exe","wget --keep-session-cookies --http-user=name@email.com --http-password=mypassword --post-data='status=This is a test tweet from HomeSeer.' http://twitter.com:80/statuses/update.xml" 
      or

      PHP Code:
      hs.launch "C:\Program Files\HomeSeer\wget.exe","wget --keep-session-cookies --http-user=name@email.com --http-password=mypassword --post-data=''status=This is a test tweet from HomeSeer.'' http://twitter.com:80/statuses/update.xml" 
      the second being two ' in a row


      ~Bill

      Comment


        #4
        JavaScript version:

        hs.launch("C:/Program Files/GnuWin32/bin/wget.exe","--keep-session-cookies --quiet --http-user=YOUR_TWITTER_USERID --http-password=YOUR_TWITTER_PASSWORD --post-data=status=\"" + VARIABLE_CONTAINING_TWEET_TEXT + "\" http://twitter.com:80/statuses/update.xml");


        sample hs twitter accounts:
        http://twitter.com/01001000
        http://twitter.com/00101010
        Last edited by IKUS; March 5, 2009, 12:37 AM.

        Comment


          #5
          Very cool... Now what do I want Homeseer to Twitter for me??? Hmmm....

          Comment


            #6
            Originally posted by GadgetBoySI View Post
            Very cool... Now what do I want Homeseer to Twitter for me??? Hmmm....
            There are so many possible uses...

            For a short period of time that I was out of town on business, I was noticing chunks of time throughout the day when my remote speaker client couldn't connect to my hs server back home. I was pretty certain it was my cable company that was acting up but not being home I couldn't prove to the tech support guy (to his satisfaction) that my internet connectivity at home was intermittently going down. I created a twitter account and setup a HS script to tweet to it every 60 seconds and then just let it rip. The next day I was able to provide the tech support guy with down-to-the-minute periods of time that my internet connectivity at home had gone down and they were able to correlate that with something they found in their logs. A couple days later when I got home, the cable installer was up on the pole replacing the drop to the property and I've had no connectivity problems since.

            Comment


              #7
              Is it possible to post the information to Twitter without using wget.exe that runs in a dos-box?


              Thanks!
              DJ

              Comment


                #8
                Thanks

                Thanks all for the replies.

                I never was able to get HS to send tweets with wget as I would have liked it to. I am, however, able to send them as long as I substitute spaces with underscores. Inelegant_but_adequate.

                I recently had to leave town on short notice. While on the road, it was (since I don't currently have the HS web server running) a great comfort to occasionally check twitter to make sure that the house still existed and that the pets were still eating.

                Anyone besides IKUS doing this?

                Comment


                  #9
                  Instead of underscores try substituting %32 for the spaces.

                  That is ascii for a [SPACE]

                  http://www.asciitable.com/


                  ~Bill

                  Comment


                    #10
                    you can use spaces but only if you use quotes around your status text. since this is embedded in a script call you can't just drop a quote in there or you mess up the call. you have to escape the quotes. using javascript below i'm escaping the quotes on eitherside of the concatenated status text variable strInput by prefixing it with a back-whack. \" is the equiv of a quote here...remember that somewhere before this snipet is an opening quote that is closed before the concatenation and somewhere after this snipet is a closing quote which is opened right after the concatenation.

                    --post-data=status=\"" + strInput + "\" http://twitter.com:80/statuses/update.xml

                    or simplified without using a variable for the status text...

                    --post-data=status=\"This is the tweet\" http://twitter.com:80/statuses/update.xml

                    the back-whack is the javascript escape character. it's been a while since I've done anything with vbscript but i seem to recall that escape charactering being different. change it up based on whatever scripting engine you're using.
                    Last edited by IKUS; April 29, 2009, 06:42 PM.

                    Comment


                      #11
                      Originally posted by Igor3 View Post
                      Thanks all for the replies.

                      I never was able to get HS to send tweets with wget as I would have liked it to. I am, however, able to send them as long as I substitute spaces with underscores. Inelegant_but_adequate.

                      I recently had to leave town on short notice. While on the road, it was (since I don't currently have the HS web server running) a great comfort to occasionally check twitter to make sure that the house still existed and that the pets were still eating.

                      Anyone besides IKUS doing this?
                      Why not use the HomeSeer web server?
                      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                      Comment


                        #12
                        Originally posted by Bill Brower View Post
                        Instead of underscores try substituting %32 for the spaces.

                        That is ascii for a [SPACE]

                        http://www.asciitable.com/
                        For URL Encoding you need to use the hex value, so for a [space] the proper representation is %20, and for simplicity it is also valid to substitute a space with a plus sign.

                        -Dave

                        Comment


                          #13
                          I'm new to twitter and would like to use HS to post to an account I have set up but having problems getting wget to work. I know nothing about javascript so I'm in need of a little hand holding.

                          What is the entire process to get this to work. I've tried to use the command posted by IKUS, but I'm getting error messages. I've tried it with a .txt and .js file without luck. Is there something in the file that must preceed or follow the command that I'm missing.

                          Much thanks.
                          Regards, Bob

                          Comment


                            #14
                            Making some progress on this. I can now send tweets to my twitter account using the following script.

                            Sub tweet(sMessage)

                            sMessage = sMessage& " ("&NewTime&")"

                            hs.launch "C:\Program Files\GnuWin32\bin\wget.exe","--keep-session-cookies --quiet --http-user=USERNAME --http-password=PASSWORD --post-data=status="&chr(34)&sMessage&chr(34)&" http://twitter.com:80/statuses/update.xml"

                            End Sub

                            Private function NewTime
                            Dim DT
                            Dim TimePart
                            Dim AMPMPart

                            DT = Time()
                            TimePart = Left(DT, Len(DT) - 6)
                            AMPMPart = Right(DT, 3)

                            NewTime = TimePart & AMPMPart

                            End function

                            I'm having to include the time stamp because if two identical messages are sent, one after the other, the second one is ignored. This is working great me me. Much better then e-mail notifications as you can subscribe or unscribe to the message service at any time using your phone and also easier as you don't need to log into your cell phone mail app to see the message - they pop right up on my iphone display! I was having recurring issues with the hs mail delivery so I was looking for good solution.

                            Next I want to see if you can send a direct message to a twitter user. No luck so far, but maybe one of you techie guys can figure this out for me.
                            Regards, Bob

                            Comment


                              #15
                              Originally posted by itanic View Post
                              Next I want to see if you can send a direct message to a twitter user. No luck so far, but maybe one of you techie guys can figure this out for me.
                              Use curl or wget to do the same thing you are already doing but format the message to the twitter API like this:

                              d recipient message

                              This will direct-message recipient with the message. Remember that in order to direct message you have to be following each other.

                              Comment

                              Working...
                              X