我想使用Twitter API(https://www.npmjs.com/package/twitter)這裏是認爲我想補充:如何使用node.js在express.js上使用twitter api顯示最後20條推文?
app.js &的package.json
var express = require("express"),
path = require("path"),
http = require("http"),
twitter = require("twitter"),
app = express();
http.createServer(app).listen(3000);
twitter_data.js
var Twitter = require('twitter');
var client = new Twitter({
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: ''
});
var params = {screen_name: 'nodejs'};
client.get('statuses/user_timeline', params, function(error, tweets, response){
if (!error) {
console.log(tweets);
}
});
感謝它的工作 –
然後,請將它標記爲已接受的答案;) –
如何更改twitter句柄我正在使用ajax get var twitterhandle = $('#twitterUsername')。val(); $就({ 類型: 'GET', 數據:{ 文本:twitterhandle }, URL: '/狀態/ user_timeline', });請分享我想添加的內容/routes/index.js –