-
-
Save geraintwhite/10013021 to your computer and use it in GitHub Desktop.
A Node.js app that allows the use of the Twitter API by client-side JavaScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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
Allows Twitter API requests from client side JavaScript.