【发布时间】:2021-01-19 07:34:15
【问题描述】:
帮助! 我试图调用这个函数,但没有像我预期的那样工作
var T = new Twit(config);
var retweet = function() {
T.get('search/tweets', {q:'#python3, #nodejs, python3, nodejs,', count :5 },
function(err, data, response){
const t_ID = data.statuses[0].id_str
const t_ID_1 = data.statuses[1].id_str
const t_ID_2 = data.statuses[2].id_str
const t_ID_3 = data.statuses[3].id_str
console.log(t_ID, t_ID_1, t_ID_2, t_ID_3)
console.log(data)
T.post('statuses/retweet/:id', { id: t_ID }, function (err, data, response) {
console.log('Posted')
})
T.post('statuses/retweet/:id', { id: t_ID_1 }, function (err, data, response) {
console.log('Posted_1')
})
T.post('statuses/retweet/:id', { id: t_ID_2 }, function (err, data, response) {
console.log('Posted_2')
})
T.post('statuses/retweet/:id', { id: t_ID_3 }, function (err, data, response) {
console.log('Posted_3')
})
} )
}
retweet();
setInterval(retweet, 80000);`
enter code here
console.log 显示
已发布_1 已发布 Posted_3 已发布_2
但 twitter 不转发或将转发 2 条,下次不转发 3 条。
加上代码很乱,谁能优化和解决我的错误?
【问题讨论】:
-
您从 Post 请求中得到的实际响应是什么?他们可能会告诉你发生了什么。
-
状态:'403 Forbidden',
-
这个相同的脚本之前运行没有问题,有什么更好的方式来发送多个 id 的 post 请求?
标签: javascript node.js npm twitter