0

我有一个用于 twitch 的小聊天机器人,我现在想创建一个可以更改流标题的功能。我的功能目前看起来是这样的:

public changeTitle = (new_title: string, callback: any): void => {
    let t = this;
    let request = require('request');
    request.get("https://api.twitch.tv/kraken/channels/" + this.settings.current_channel + "?client_id="+this.settings.clientId, { json: true }, function (err, res) {
        if (!err && res.statusCode === 200) {
            let current_title = res.body.status;
            console.log(current_title);
            let request2 = require('request');
            let options = {
                url: "https://api.twitch.tv/kraken/channels/"+t.settings.current_channel+"?channel[status]="+current_title+new_title,
                headers: {
                    "Authorization": "OAuth "+t.settings.clientId,
                    "Accept": "application/vnd.twitchtv.v2+json"
                }
            };
            request2.put(options, (error: Error, response: any, body: any): void => {
                console.log("Title changed?");
            });
        }
    });
};

在 console.log(current_title) 我可以看到当前的流标题。在 console.log("Title changed?") 之后什么也没发生。我收到错误 410 GONE。所以不再支持我更改标题的方式。有人可以告诉我如何更改标题吗?

提前致谢 :)

4

1 回答 1

0

更新频道似乎涵盖了这一点

具体来说,而不是channel[status]仅用status作查询参数。

let options = {
            url: "https://api.twitch.tv/kraken/channels/"+t.settings.current_channel+"?status="+new_title,
            headers: {
                "Authorization": "OAuth "+t.settings.clientId,
                "Accept": "application/vnd.twitchtv.v2+json"
            }

您还需要channel_editor范围才能在给定通道上使用它。

于 2017-07-24T17:20:32.773 回答