Twitter api reply to tweet

让人想犯罪 __ 提交于 2021-02-19 04:52:22

问题


I'm trying to write a script to reply to a tweet, using the twit npm module. However whenever I pass the in_reply_to_status_id_str or in_reply_to_status_id this seems to be ignored. Not sure what the issue is?

   T.get('search/tweets', { q: `golf since:2011-07-11`, count: 1 }).then(function (response) {

            const userName = response.data.statuses[0].user.screen_name;
            const tweetId = response.data.statuses[0].id_str;

            T.post('statuses/update', { in_reply_to_status_id_str: tweetId, status: `@${userName}, I like golf too` }, (err, data, response) => {
              resolve()
            })
          })

        })

回答1:


You should be passing the param as in_reply_to_status_id instead of in_reply_to_status_id_str.

T.get('search/tweets', { q: `golf since:2011-07-11`, count: 1 }).then(function (response) {

            const userName = response.data.statuses[0].user.screen_name;
            const tweetId = response.data.statuses[0].id_str;

            T.post('statuses/update', { in_reply_to_status_id: tweetId, status: `@${userName}, I like golf too` }, (err, data, response) => {
              resolve()
            })
          })

        })


来源:https://stackoverflow.com/questions/54729379/twitter-api-reply-to-tweet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!