节点对推文的回复实际上并没有回复

Node reply to tweet does not actually reply

我正在使用 Twit 节点库来回复流中的推文,虽然它运行良好,但推文回复不会显示为时间轴上的回复,而是显示为独立的推文,未链接到之前的对话。

这是我的代码:

function tweetEvent(eventMsg) {
    var replyto = eventMsg.in_reply_to_screen_name;
    var text = eventMsg.text;
    var from = eventMsg.user.screen_name;

    console.log(replyto + ' ' + from);

    if( (text.indexOf('myhandle') >= 0) || (from != 'myhandle')) {
        var reply = replies[Math.floor(Math.random() * replies.length)];
        var newtweet = '@' + from + ' ' + reply;
        tweetIt(newtweet);
    }
}

function tweetIt(txt) {

    var tweet = {
      status: txt
    }

    T.post('statuses/update', tweet, tweeted);

    function tweeted(err, data, response) {
      if (err) {
        console.log("Something went wrong!");
      } else {
        console.log("It worked!");
      }
    }
}

为了使用 Twitter API 将回复显示在时间轴中,您需要满足以下条件:

// the status update or tweet ID in which we will reply
var nameID  = eventMsg.id_str;

还需要 tweet status 中的参数 in_reply_to_status_id。请参阅下面的代码更新,它现在应该保留对话:

function tweetEvent(eventMsg) {
    var replyto = eventMsg.in_reply_to_screen_name;
    var text = eventMsg.text;
    var from = eventMsg.user.screen_name;
    // the status update or tweet ID in which we will reply
    var nameID  = eventMsg.id_str;


    console.log(replyto + ' ' + from);

    if( (text.indexOf('myhandle') >= 0) || (from != 'myhandle')) {
        var reply = replies[Math.floor(Math.random() * replies.length)];
        var newtweet = '@' + from + ' ' + reply;
        tweetIt(newtweet);
    }

    function tweetIt(txt) {

        var tweet = {
          status: txt,
          in_reply_to_status_id: nameID
        }
}

    T.post('statuses/update', tweet, tweeted);

    function tweeted(err, data, response) {
      if (err) {
        console.log("Something went wrong!");
      } else {
        console.log("It worked!");
      }
    }
}