in

WebBrick Twitter Interface

Last post 05-28-2010 12:24 PM by andy.harris. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-04-2009 4:21 PM

    WebBrick Twitter Interface

     Here's something fairly simple, get your WebBrick gateway to Twitter.

     As a word of caution, don't attach this to the home/away event otherwise twitterers like B.Urglar will know the status of you house.

     

  • 05-27-2010 5:28 PM In reply to

    Re: WebBrick Twitter Interface

    Hi, The link isn't working anymore - can you repost pls. Thanks Paul
  • 05-28-2010 12:23 PM In reply to

    Re: WebBrick Twitter Interface

     Ok, Lets upload the file again.

     

    Regards

     

    Andy

  • 05-28-2010 12:24 PM In reply to

    Re: WebBrick Twitter Interface

     Ok that doesn't work -- I'll get someone to work out what's happened with storage, in the meantime here is the code:

     #
    #  Send a status via Twitter, takes user,pass and msg from the command line
    #
    #  Andy Harris, WebBrick Systems, no rights reserved
    #  4th August 2009
    #
    import getopt, sys, twitter


    def main():
        try:
            opts, args = getopt.getopt(sys.argv[1:], "h:v", ["help", "msg=","user=","pass="])
        except getopt.GetoptError, err:
            print str(err) # will print something like "option -a not recognized"
            usage()
            sys.exit(2)

        message = None
        username = None
        password = None
        verbose = False

        print "The opts %s" % opts
        for o, a  in opts:
            if o == "-v":
                verbose = True
            elif o in ("-h", "--help"):
                usage()
                sys.exit()
            elif o in ("-m", "--msg"):
                print "o %s and a %s" % (o,a)
                message = a
            elif o in ("-u", "--user"):
                print "o %s and a %s" % (o,a)
                username = a
            elif o in ("-p", "--pass"):
                print "o %s and a %s" % (o,a)
                password = a
            else:
                assert False, "unhandled option"

        api = twitter.Api(username,password)
        api.PostUpdate(message)


    def usage():
        print "Usage problem, check your params --user uname --pass passwd --msg theMessage"

    if __name__ == "__main__":
        main()

     

Page 1 of 1 (4 items)
(c) WebBrick Systems