Skip to content

Instantly share code, notes, and snippets.

@diorahman
Created July 30, 2012 05:35
Show Gist options
  • Save diorahman/3205120 to your computer and use it in GitHub Desktop.
Save diorahman/3205120 to your computer and use it in GitHub Desktop.
dm
server.all('/twitter/:version/:resource?/:id?/:endpoint', function(req, res, next){
var oauth = {
consumer_key: CONSUMER_KEY,
consumer_secret: CONSUMER_SECRET,
token : "17058778-hl3kiwpXnSW0H8Iup3YInX9Pk0McTwMOPN9ezS4Ly",
token_secret : "9cRTAQHDo8ds9J9U4GfxAnWd6ngPZiztyY5zMvOK7k"
}
var header = req.headers['content-type'] ? req.headers['content-type'] : "";
url = (header.indexOf('multipart') > -1 ? UPLOAD : API)
url += '/' + req.params.version
url += req.params.resource ? '/' + req.params.resource : ""
url += (req.params.id ? ('/' + req.params.id) : '') + '/' + req.params.endpoint
url += req.query ? ('?' + qs.stringify(req.query)) : ""
var options = {
url : url,
oauth : oauth,
body : req.rawBody ? req.headers['content-type'].indexOf('multipart') > -1 ? req.rawBody : req.rawBody.toString() : '',
method : req.method,
headers : {
'content-type' : req.headers['content-type'] ? req.headers['content-type'] : 'application/json'
}
}
request(options).pipe(res)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment