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, ping an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members) or send an e-mail to admin@wiki.whatwg.org with your desired username and an explanation of the first edit you'd like to make. (Do not use this e-mail address for any other inquiries, as they will be ignored or politely declined.)

Note: This wiki is used to supplement, not replace, specification discussions. If you would like to request changes to existing specifications, please use IRC or a mailing list first.

WebAppsTweet

From WHATWG Wiki
Jump to: navigation, search

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."
Personal tools
Namespaces

Variants
Actions
Navigation
WHATWG
Registries
Toolbox