I use OAuth module from NPM to get data from Twitter, but only get not complete JSON file as:
{"code":12,"name":"Country"},"url":"http://where.yahooapis.com/v1/place/23424801","parentid":1,"country":"Ecuador","woeid":23424801,"countryCode":"EC"},{"name":"Egypt","placeType":{"code":12,"name":"Country"},"url":"http://where.yahooapis.com/v1/place/23424802","parentid":1,"country":"Egypt","woeid":23424802,"countryCode":"EG"},{"name":"Ireland","placeTyp <- end here
With server.js file:
var http = require('http');
var Oauth = require('oauth');
var url = require('url');
var util = require('util');
var CONSUMER_KEY = "";
var CONSUMER_SECRET = "..............";
var ACCESS_TOKEN = "......";
var ACCESS_TOKEN_SECRET = ".....";
var oauth = new Oauth.OAuth(
"https://api.twitter.com/oauth/request_token",
"https://api.twitter.com/oauth/access_token",
CONSUMER_KEY,
CONSUMER_SECRET,
"1.0A",
null,
"HMAC-SHA1");
http.createServer(function (req, res) {
var pathName = url.parse(req.url).pathname
if (pathName == '/trends') {
oauth.get(
'https://api.twitter.com/1.1/trends/available.json',
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET,
function (e, data, r) {
util.inspect(req);
if (e) console.log(e);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(data);
}
);
} else {
res.writeHead(400);
res.end();
}
}).listen(process.env.PORT || 8080);