Skip to content

Instantly share code, notes, and snippets.

@weisjohn

weisjohn/chirps.js

Created Dec 15, 2015
Embed
What would you like to do?
// configure twitter integration
var twit = require('twit');
var T = new Twit({
consumer_key: '...'
, consumer_secret: '...'
, access_token: '...'
, access_token_secret: '...'
});
// express app
var express = require('express');
var app = express();
// routes
app.get('/tweets', function (req, res) {
// your FE code will just need to specify any params
var query = req.query;
query.count = 100;
// console.log(req.query)
T.get('search/tweets', query, function(err, data, response) {
if (err) return res.status(500).json(err);
res.status(200).json(data);
});
});
// start server
var server = module.exports = require('http').createServer(app);
server.app = app;
// only start listening if required
if (!module.parent) server.listen(app.get('port'), function() {
console.log('listening', 8000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.