我需要有关如何从twitter api获取数据一周的帮助。 我使用nodeJs来编写代码,但它似乎不能很好地工作。
我在nodeJs btw中使用twit模块。
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1; //January is 0!
var year = today.getFullYear();
let months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
for (let i = 0; i < 7; i++) {
if (day > 0) {
day--;
}
if (day == 0) {
month = month - 1;
day = months[month - 1];
}
console.log(day, month, year);
}
let params = {
q: `to:${firstBrand} since:${year}-${month}-${day-1} until:${year}-${month}-${currentDay}`,
count: 5000,
language: 'en',
entities: false
};
let param = {
q: `to:${secondBrand} since:${year}-${month}-${day-1} until:${year}-${month}-${currentDay}`,
count: 5000,
language: 'en',
entities: false
};
t.get('search/tweets', params, dataGotten);
答案 0 :(得分:1)
假设您的所有设置都正确完成:
CREATE TABLE CHARSET
( CHARSET_CODE varchar(15),
CHARSET_DESCRIPTION varchar(50),
APP_REGI_DATE date,
APP_UPD_DATE date,
CREATED_BY varchar(20),
CREATION_DATE date,
UPDATED_BY varchar(20),
UPDATE_DATE date,
LOCALE_CODE varchar(20),
constraint PK_80 PRIMARY KEY (CHARSET_CODE));
我会试试这个:
const Twit = require('twit')
const T = new Twit({
consumer_key: '...',
consumer_secret: '...',
access_token: '...',
access_token_secret: '...',
timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
});
顺便说一下,t.get('search/tweets', params, function(err, data) {
console.log(data);
});
是可选参数,所以首先尝试没有它们的工作方式:
params