Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //uses https://github.com/ciaranj/node-oauth/wiki/Example-usage-example-for-Tweeting-with-Twitter
- var OAuth= require('./lib/oauth').OAuth;
- var http = require('http');
- http.createServer(function (req, res) {
- console.log("req handled" + req.url);
- var u = require('url').parse(req.url, true);
- if(u.query.q)
- {
- console.log("tweet: " + u.query.q);
- oAuth= new OAuth("http://twitter.com/oauth/request_token",
- "http://twitter.com/oauth/access_token",
- "twitterConsumerKey", "twitterConsumerSecret",
- "1.0A", null, "HMAC-SHA1");
- oAuth.post("http://api.twitter.com/1/statuses/update.json", "twitterAccessToken",
- "twitterAccessTokenSecret", {"status": u.query.q}, function(error, data) {
- if(error) console.log(require('sys').inspect(error))
- else console.log("Tweet success")
- });
- res.writeHead(302, {'Location': 'http://www.google.com/#sclient=psy&q='+u.query.q});
- res.end('\n');
- }
- else
- {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end('It broke... :/ \n');
- }
- }).listen(25252);
- console.log('Server running on 25252');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement