简体   繁体   English

错误:不正确的Twitter流请求:使用Twit的401

[英]Error: Bad Twitter streaming request: 401 using Twit

This is the code that is not working: 这是不起作用的代码:

var Twit = require('twit'); //Using Twit
    var config = require('./config'); //Loading tokens
    var T = new Twit(config); //Applying tokens

    var stream = T.stream('user');
    console.log("" + T.getAuth().name);
    //console.log("stream init");

    function followed(eventMsg) {
        console.log("function called");
        var name = eventMsg.source.screen_name;
        makeTweet("thx for follow @" + name);
    };

    stream.on('tweet', followed);

I am getting the error code in the title, however this does work: 我在标题中得到错误代码,但这确实起作用:

function makeTweet(text) {
    var tweet = {
        status: text
    };

    function tweeted(err, data, response) {
        if(!err) {
            console.log("Tweet posted");
        } else {
            console.log("FAIL!");
        }
    }

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

Do you have any idea what could help? 您知道有什么帮助吗? I already tried: - Regenerating the access tokens - Using different stream endingPoints - using "app_only_auth: true" in config.json 我已经尝试过:-重新生成访问令牌-使用不同的流终结点-在config.json中使用“ app_only_auth:true”

Twitter user streams are no longer available and were retired on August 23rd, 2018 . Twitter用户流不再可用, 并已于2018年8月23日停用 This code will not work. 此代码将不起作用。 You will need to use the Account Activity API instead. 您将需要改用Account Activity API。

Additionally, your code would violate Twitter's automation rules. 此外,您的代码将违反Twitter的自动化规则。 You should check those before writing a bot to automatically Tweet to new followers. 您应该先检查这些内容,然后再编写自动将Tweet推给新关注者的机器人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM