Update Twitter banner background using Will Burn’s Colorfulgradients.
Generate Image
request = require "request"
cheerio = require "cheerio"
URL = "//colorfulgradients.tumblr.com/random"
module.exports = (cb) ->
request URL, (err, res, html) ->
$ = cheerio.load(html)
imgUrl = $(".photo-wrapper img").first().attr("src")
options =
url: imgUrl
encoding: null
request options, (err, r, body) -> cb(body)
Uploader
Twit = require "twit"
Constants = require "./constants"
URL = "account/update_profile_banner"
module.exports = (body, cb) ->
b64 = new Buffer(body).toString("base64")
T = new Twit(Constants)
T.post URL, banner: b64, -> cb()
Source is here