Skip to content

Instantly share code, notes, and snippets.

@olls
Last active August 29, 2015 13:57
Show Gist options
  • Save olls/9609348 to your computer and use it in GitHub Desktop.
Save olls/9609348 to your computer and use it in GitHub Desktop.
/*
A simple Node.js proxy for Twitter's OAuth API.
*/
var http = require('http');
var url = require('url');
var t = require('twitter-js-client');
var twitter = new t.Twitter({
"consumerKey": "###",
"consumerSecret": "###",
"accessToken": "###",
"accessTokenSecret": "###",
"callBackUrl": "http://dvbris.com"
});
http.createServer(function (req, res) {
var url_parts = url.parse(req.url, true);
res.writeHead(200, {'Content-Type': 'application/json'});
function error(err) {
res.end(JSON.stringify(err));
}
function success(data) {
res.end(data);
}
twitter.doRequest(decodeURIComponent(url_parts.query.api_url), error, success);
}).listen(6001);
console.log('Server running at localhost:6001');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment