Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript I';我正在尝试使用Node.js上的Twit回复tweet_Javascript_Node.js_Twitter - Fatal编程技术网

Javascript I';我正在尝试使用Node.js上的Twit回复tweet

Javascript I';我正在尝试使用Node.js上的Twit回复tweet,javascript,node.js,twitter,Javascript,Node.js,Twitter,不确定如何输入in_reply_to_status_id 它在推特上发得很好,只是没有回复推特上提到的内容 in_reply_to_status_id是Twitter API的一部分,Twit可以访问该API,但是我可以在这个上下文中使用它吗 任何帮助都将不胜感激 代码如下: var stream = T.stream('statuses/filter', { track: '@example'}); io.on('connection', function (socket) { sock

不确定如何输入in_reply_to_status_id

它在推特上发得很好,只是没有回复推特上提到的内容

in_reply_to_status_id是Twitter API的一部分,Twit可以访问该API,但是我可以在这个上下文中使用它吗

任何帮助都将不胜感激

代码如下:

var stream = T.stream('statuses/filter', { track: '@example'});

io.on('connection', function (socket) {
  socket.on('chat message', function (msg) {
    console.log('message: ' + msg);
    P.post('statuses/update', { status: '@example' + ' ' + msg}, function (err, data, response) {
      socket.emit('info', data.text);
      socket.emit('userPic', data.user.profile_image_url);
      console.log(data.user.profile_image_url);
    });
  });

  stream.start();

  stream.on('tweet', function (tweet) {
    console.log(tweet);
    // console.log('listening to tweets');

    if (tweet.text.indexOf('@example') > -1) {
      console.log("there is a tweet");
      var number = Date.now();
      var reply = replies[Math.floor(Math.random() * replies.length)];
      var name = '@' + tweet.user.screen_name;
      T.post('statuses/update', {in_reply_to_status_id: [name], status: reply + ' ' + number + ' ' + name}, function (err, data, response) {
        console.log(reply + number);
        socket.emit('reply', data.text);
      });
    }
  });
});

未正确分析用户名ID字符串。解决方案:

var nameID = tweet.id_str;

var name = tweet.user.screen_name;

T.post('statuses/update', {in_reply_to_status_id: nameID, status: reply + ' ' + number + ' @' + name}, function(err, data, response) {