A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
WebAppsTweet: Difference between revisions
Jump to navigation
Jump to search
(Created page with 'WebAppsTweet is a simple script responsible for updating [http://twitter.com/WHATWG @WHATWG] on Twitter whenever the specification is changed. It is written on top of [https://gi...') |
(ignore typo and xref fixes) |
||
Line 24: | Line 24: | ||
pass | pass | ||
if revision: | if revision and message != "typo" and message != "xref": | ||
shorturl = "http://html5.org/r/" + revision | shorturl = "http://html5.org/r/" + revision | ||
message = shorturl + " — " + message | message = shorturl + " — " + message |
Revision as of 11:08, 20 January 2011
WebAppsTweet is a simple script responsible for updating @WHATWG on Twitter whenever the specification is changed. It is written on top of Twython. This page documents most of its source code, which you are free to use for any purpose.
#!/usr/bin/python # coding=UTF-8 # The parameters passed are rev/message/flags/bug/level import cgi from twython import Twython consumer_key = "..." consumer_secret = "..." oauth_token = "..." oauth_secret = "..." form = cgi.FieldStorage() revision = "" message = "" try: revision = form["rev"].value message = form["message"].value except: pass if revision and message != "typo" and message != "xref": shorturl = "http://html5.org/r/" + revision message = shorturl + " — " + message if len(message) > 140: message = message[:139] + "…" twitter = Twython( twitter_token = consumer_key, twitter_secret = consumer_secret, oauth_token = oauth_token, oauth_token_secret = oauth_secret ) print "Content-Type:text/plain\n" print twitter.updateStatus(status=message) else: print "Content-Type:text/plain\n" print "Not today. Not today."